sudoku dictionary attack

Jonathan jrivet at ameritech.net
Mon Jun 20 13:06:38 EDT 2005



sub1ime_uk at yahoo.com wrote:
> Thought I'd offer a method for solving all possible 9x9 sudoku puzzles
> in one go. It'll takes a bit of time to run however (and 9x9 seems to
> be about as big as is reasonably possible before combinatorial
> explosion completely scuppers this type of program)...
>
> Basic idea:-
>
> Start with a grid initialised with:
>
> 123456789
> 234567891
> 345678912
> 456789123
> 567891234
> 678912345
> 789123456
> 891234567
> 912345678
>
> Note that all rows and columns contain all 9 digits (but that the
> sub-tiles aren't correct for a sudoku solution).
>
> Next write a program which permutes all 9 columns, and then for each of
> those permutations permutes the last 8 rows. This will, I believe,
> generate all possible grids with no digit repetitions in any row or
> column. It will generate 14,631,321,600 (9!*8!) possible sudoku
> candidates. Finally, check each candidate to see if any 3x3 subtile has
> a repeated digit in it and discard as soon as a repeat is found (sooner
> the better). Any that come through unscathed get written as a 82 (81 +
> lf) char string to an output file.

I'm having trouble coming up with anything that fits this grid:

..12.....
..2x.....
.........
.........
.........
.........
.........
.........
.........

where x is not 3, by permuting columns, then rows.  You may also have
to permute the numbers.  Although, even then, x=1 is still impossible.




More information about the Python-list mailing list