Sudoku solver
Frank Millman
frank at chagford.com
Thu Mar 26 04:19:48 EDT 2015
"Marko Rauhamaa" <marko at pacujo.net> wrote in message
news:87r3sdnw5t.fsf at elektro.pacujo.net...
>
>
> I post below a sudoku solver. I eagerly await neater implementations (as
> well as bug reports).
>
Here is another python-based sudoku solver -
http://www.ics.uci.edu/~eppstein/PADS/Sudoku.py
>From its docstring -
"A proper Sudoku puzzle must have a unique solution, and it should be
possible to reach that solution by a sequence of logical deductions without
trial and error. To the extent possible, we strive to keep the same ethic
in our automated solver, by mimicking human rule-based reasoning, rather
than resorting to brute force backtracking search."
A neat feature is that, having printed the solution, it then lists every
step it took in its reasoning process to arrive at the solution.
It solved Marko's original puzzle and Ian's puzzle in less than a second. It
could not solve Marko's second one, returning "impossible" immediately.
Here is another one that does not use python, but uses SQL -
https://www.sqlite.org/lang_with.html
You will find it at the bottom of the page, under the heading "Outlandish
Recursive Query Examples".
Frank Millman
More information about the Python-list
mailing list