Soduku

Jonathan Gardner jgardner at jonathangardner.net
Tue Feb 14 22:36:47 EST 2006


27ms == 0.027s

How do you have a 16x16 grid for soduku? Are you using 16 digits? 0-F?

The one I am using has 9 digits, 9 squares of 9 cells each, or 9x9
cells.

The least efficient part of the algorithm is that part to calculate
what to put in a hole (as anyone might've guessed.) My algorithm
calculates this by using a set of possible values. Then I visit each
cell in the same row, column, and square, removing values from the set.
What's left is the possible values. If there is only one possible
value, then I've found what belongs there. The soduku puzzle I was
using for a test can be solved without making any guesses in this way.

The guy's algorithm was visiting each empty square and then trying out
numbers from 1-9. If they didn't violate the rules (by examining each
cell in the row, column, and square for each guess), then he would move
to the next empty cell and try again, until he got the solution. There
was a lot of backtracking and it would even try to find all possible
answers.




More information about the Python-list mailing list