man sudoku




NAME

  sudoku  - sudoku solver


SYNOPSIS

  sudoku -options


DESCRIPTION

  Solve  9x9 sudoku puzzles via logic (vs. "brute force").  The puzzle
  is read from stdin.  A total of 81 values must be read,  expectation
  is  reading  9  rows  of  9 values but any number may be entered per
  line.  Use zero (0) for an unknown value.  Characters '.*x' will  be
  interpreted  as  a  zero.   Spaces or any punctuation are considered
  delimeters and are ignored.  A puzzle can also be read as 81 consec-
  utive digits [0-9].

  In  the  case of non-unique puzzles, two solutions will be displayed
  (there may be more).  In the case of impossible puzzles, solver will
  stop  indicating  where it detected the problem.  Options allow dis-
  play of solution progress.


OPTIONS

  -help  Display terse usage information.

  -example N
         Use a pre-coded example, where N  is  one  of  17  (or  more)
         internal  examples.  Example 8 is non-unique and example 9 is
         invalid.  Example 12 is a case where "logic" fails but  there
         is only one unique "brute" solution.

  -f     Option to display all pre-coded examples.

  -level L
         Initial  level  to start solving.  Solution is done in levels
         masking to determine possible values for a  row,  column,  or
         box.   Typically solver starts from level-1 and works up to 6
         if necessary.  Most puzzles  are  solved  by  level-2.   This
         option is primarily for geek-ish interests.

  -brute B
         Number of unique solutions to display when resorting to brute
         (trial and error), defaults to 2.  Specificy 0 for all possi-
         ble  solutions.   Note, examples 12 and 17 both require brute
         algorithm but have only have one solution  (or  my  logic  is
         flawed).

  -maximum M
         Maximum level to attempt solution.  This option is useful for
         trying to learn how to solve sudoku puzzles with your noggin.

  -show S
         Specify    "show  level"  for  solution  progress.   The  'S'
         defaults as 0 and is a bit mask where:
          0  initial/results only
          1  possible values
          2  eliminated values
          4  octal mask of possible values

         The mask is powers of two for numeric values.   For  example,
         if an entry can be only 1 or 4, the mask is:
           2**(1-1) | 2**(4-1) : 1 | 8 : 9 : 0o0101

         For  more  information on how the solver works, read the com-
         ments at start of solver.c source code.

  -initial
         Show initial values only.  This is useful for validating that
         puzzle has no duplicate entries.

  -progress
         Show progress to solution.

  -quiet Turns off prompt for interactive puzzles and does not display
         initial values.

  -verbose
         Display at various partial solution points.

  -z     Option to display in von der Burg format (81 digits).


EXAMPLES

   iceberg2: sudoku -example 3
   _Pocket Sudoku_ Volume 3, #145
   'Beware! Very Challenging!' (Will Shortz)
   Level -1 Known 22, Unknown 59, Solved 0, Errors 0
   +---------------+---------------+---------------+
   | (2)  (1)   .  |  .    .    .  |  .    .    .  |
   |  .    .    .  |  .    .   (3) | (1)   .    .  |
   |  .    .   (9) | (4)   .    .  |  .    .   (7) |
   +---------------+---------------+---------------+
   | (8)  (2)  (5) |  .    .   (4) |  .    .    .  |
   |  .    .    .  | (6)   .    .  |  .    .    .  |
   | (1)   .    .  |  .    .   (8) | (2)   .    .  |
   +---------------+---------------+---------------+
   |  .   (7)   .  |  .   (9)   .  |  .    .    .  |
   |  .    .    .  |  .   (3)  (1) |  .   (4)   .  |
   |  .    .    .  |  .    .    .  | (3)  (8)   .  |
   +---------------+---------------+---------------+

   _Pocket Sudoku_ Volume 3, #145
   'Beware! Very Challenging!' (Will Shortz)
   Level  3 Known 22, Unknown 0, Solved 59, Errors 0
   +---------------+---------------+---------------+
   | (2)  (1)   8  |  9    6    7  |  4    3    5  |
   |  5    4    7  |  2    8   (3) | (1)   9    6  |
   |  3    6   (9) | (4)   1    5  |  8    2   (7) |
   +---------------+---------------+---------------+
   | (8)  (2)  (5) |  1    7   (4) |  9    6    3  |
   |  7    3    4  | (6)   2    9  |  5    1    8  |
   | (1)   9    6  |  3    5   (8) | (2)   7    4  |
   +---------------+---------------+---------------+
   |  4   (7)   3  |  8   (9)   2  |  6    5    1  |
   |  6    8    2  |  5   (3)  (1) |  7   (4)   9  |
   |  9    5    1  |  7    4    6  | (3)  (8)   2  |
   +---------------+---------------+---------------+

   iceberg2: ./sudoku
   Row 1: 0,0,0,8,0,0,5,0,0
   Row 2: 0,0,0,9,0,7,8,0,0
   Row 3: 6,4,0,0,0,0,0,0,0
   Row 4: 0,3,0,0,0,0,0,4,1
   Row 5: 0,0,0,0,1,0,0,0,0
   Row 6: 5,2,0,0,0,0,0,7,0
   Row 7: 0,0,0,0,0,0,0,1,5
   Row 8: 0,0,5,4,0,2,0,0,0
   Row 9: 0,0,2,0,0,8,0,0,0

   Level -1 Known 21, Unknown 60, Solved 0, Errors 0
   +---------------+---------------+---------------+
   |  .    .    .  | (8)   .    .  | (5)   .    .  |
   |  .    .    .  | (9)   .   (7) | (8)   .    .  |
   | (6)  (4)   .  |  .    .    .  |  .    .    .  |
   +---------------+---------------+---------------+
   |  .   (3)   .  |  .    .    .  |  .   (4)  (1) |
   |  .    .    .  |  .   (1)   .  |  .    .    .  |
   | (5)  (2)   .  |  .    .    .  |  .   (7)   .  |
   +---------------+---------------+---------------+
   |  .    .    .  |  .    .    .  |  .   (1)  (5) |
   |  .    .   (5) | (4)   .   (2) |  .    .    .  |
   |  .    .   (2) |  .    .   (8) |  .    .    .  |
   +---------------+---------------+---------------+

   Level  2 Known 21, Unknown 0, Solved 60, Errors 0
   +---------------+---------------+---------------+
   |  2    7    9  | (8)   4    1  | (5)   6    3  |
   |  1    5    3  | (9)   6   (7) | (8)   2    4  |
   | (6)  (4)   8  |  5    2    3  |  1    9    7  |
   +---------------+---------------+---------------+
   |  9   (3)   7  |  2    8    5  |  6   (4)  (1) |
   |  4    8    6  |  7   (1)   9  |  3    5    2  |
   | (5)  (2)   1  |  6    3    4  |  9   (7)   8  |
   +---------------+---------------+---------------+
   |  8    9    4  |  3    7    6  |  2   (1)  (5) |
   |  3    1   (5) | (4)   9   (2) |  7    8    6  |
   |  7    6   (2) |  1    5   (8) |  4    3    9  |
   +---------------+---------------+---------------+


ACKNOWLEDGEMENTS

  Written using University of  Alaska,  Arctic  Region  Supercomputing
  Center (ARSC) resources just for fun.


RELATED INFORMATION

  The following web page describes more about this program:

  http://people.arsc.edu/~kcarlson/SudokuSolver.html

  Have fun.