Sudoko program
This is
my contribution to the infinite list of sudoku solvers. The syntax is
sudoku.pl [-<#>] [-r] [-s <symbols>] [-p <xx>] [<filename>]
Here
- <#> is 2, 3, 4, or 5 giving the size of the problem (3 is
default)
- -r turns on randomness in initial permutations. This does not
affect unique solutions but changes the order in which solutions are
found. This can be useful for generating new sudokus if you don't want
them to start out with 123456789 etc.
- -s <symbols> sets the symbols used to the symbolstring
which should be of the obvious size. Defaults are 1234, 123456789,
0123456789ABCDEF, and ABCDEFGHIJKLMNOPQRSTUVWXY for the different sizes.
- <filename> is a file to read the puzzle from. The format
should be obvious from the example below. The dots can be replaced by
any non whitespace characters not in the symbol string. Whitespaces are
ignored. If no filename is given the programs assumes an empty
grid to start with.
- if -p <xx> is given the program replaces xx percent of the
symbols in the input filename by dots. In this case the effective new
puzzle with more dots is printed at the start. This option can be used
to create new puzzles: First run the program with -r and with no
filename to generate a solution. Copy that to a file which in a second
run using that as the input file now with -p adjusted to make the
problem hard but with still a unique solution.
Here is a sample input file (taken from this week's sudoku in Die Zeit):
3.......4
.249.786.
..8...7..
.3.518.2.
.4.....5.
.5.429.7.
..6...2..
.836.294.
2.......7
Have fun!
Back to main page. Author: Robert C. Helling