Lots of changes. It appears to be working ... have to check.
Better display of the solution
Gives all solutions, but a bit buggy for big values of N