Sudoku solver
Introduction
This sudoku solver can (should be able to) solve any normal sudoku puzzle that has a square size with square sub blocks. These include the normal size (9x9), the smaller sized 4x4 sudoku and the bigger 16x16 sudoku. It uses the command line parser module that is separately available on this website.
Grids can be supplied to the program in two ways. The first one by supplying a filename that contains the initial grid and secondly, by directly typing the initial grid at the command line. All valid options can be viewed by starting the program as follows:
$./test_sudoku_solver --help
Limitations
gfortran is unable to compile all modules in the archive, but it compiles fine with g95 and ifort.
Sources
The modules and a test program can be downloaded here as a compressed tar archive. These archives do not contain build files, but using g95 or ifort, the module library and program can be build as follows:
$ wget http://users.telenet.be/tuinbels/fortran/m_sudoku_solver-2.0.tgz
$ tar -xzf m_sudoku_solver-2.0.tgz
$ cd m_sudoku_solver
$ g95 -c -o m_precision.o m_precision.F90
$ g95 -c -o m_option_parser.o m_option_parser.F90
$ g95 -c -o m_sudoku_solver.o m_sudoku_solver.f90
$ g95 -o tss test_sudoku_solver.f90 m_sudoku_solver.o m_option_parser.o m_precision.o
$ ./tss -v
License
The sources are licensed under a 3-clause BSD license.
Sample input files
This archive contains some sample input files that were all solved by this solver. Extract the archive in the same directory as where the binary is located. The solver can now be used as follows:
$ wget http://users.telenet.be/tuinbels/fortran/sudoku_test_puzzles.tgz
$ tar -xzf sudoku_test_puzzles.tgz
$ ./tss -v -f ./sudoku_test_puzzles/qassim_hamza
no input grid supplied
input file supplied
start grid:
...|7..|8..
...|.4.|.3.
...|..9|..1
---+---+---
6..|5..|...
.1.|.3.|.4.
..5|..1|..7
---+---+---
5..|2..|6..
.3.|.8.|.9.
..7|...|..2
found a valid solution:
329|716|854
176|845|239
458|329|761
---+---+---
643|572|918
712|938|546
895|461|327
---+---+---
581|294|673
234|687|195
967|153|482
elapsed time: 0.286956