Dancing Links sudoku solver

This is a sudoku solver. The solver turns sudoku puzzle into exact cover problem and solves that using Donald Knuth's Dancing Links (DLX for short) technique.

The program consists of two parts, the DLX library and a sudoku solver on top of the library. Because of the generality of the exact cover formulation, the program is not limited to standard 9x9 sized sudokus, but works also on smaller and larger (currently up to 36x36) boards. It will also solve improper sudokus, which have more than one solution, printing out all valid solutions if required.

The solver is written in Python and will thus run on any platform that has Python interpreter. This is command line tool, there is no graphical user interface.

Download

The source code is available under GNU General Public License.

You can either download the actual python scripts dlx.py and sudoku.py or a tar file that includes those files plus some sample sudoku problems.

Usage

python sudoku.py sudoku.file

where 'sudoku.file' is name of the file containing sudoku puzzle with empty cells marked with '.' or '0' and givens with numers 1 through 9 (and A-Z and & for larger sudokus)

or

python sudoku.py -s .4398.25.6..425...2....1.949....4..33..6.8...41.2.9..882.5....9....4...253489....

to give the sudoku on the command line.

Add command line option -a to find all solutions.


Antti Ajanki