by BoxJam on Tue Sep 13, 2005 6:55 am
ALright. I'll do that when I get a chance.
Basically it does the same thing people do -
-in a row, column, or box, if there are 8 squares filled in, it knows the ninth.
-for a square, if its three groups (row, column and box) have 8 distinct values, it know itself.
-for all the unsolved squares in a group, if there is only one that can contain a value, it must be that value (like 3 squares, A, B, and C, have possible values 1,4,9, 4,9 and 4,9 - A must be 1).
THere are a couple other possible rules - if a group has *2* boxes which can only take the same 2 possible values, no other square can contain it. Like A, B, C, D have possible values 1,4,6,9, 1,3,6,9 6,9 and 6,9. Since C and D must be 6 and 9 or 9 and 6, A and B's possibilities are really only 1,4, and 1,3. I didn't implement this rule.
After that, it just takes guesses - it finds the square with the fewest possibilities, and follows each possibility down the rabbit hole. Eventually, for each, you get to a point where you see it's impossible, or you get to the next part where you have to guess, or it's complete.
If you know those rules, a Sudoku becomes pretty much a matter of not making clerical errors. We deserve better.
I'll post the code for the solver classes when I get a chance.