An open API service indexing awesome lists of open source software.

https://github.com/hartwork/constraint-sudoku-solver

:game_die: Simple command line Sudoku solver making use of the python-constraint library
https://github.com/hartwork/constraint-sudoku-solver

Last synced: over 1 year ago
JSON representation

:game_die: Simple command line Sudoku solver making use of the python-constraint library

Awesome Lists containing this project

README

          

About
-----
*constraint-sudoku-solver* is

* a simple https://en.wikipedia.org/wiki/Sudoku[Sudoku] solver

* making use of
https://labix.org/python-constraint[the python-constraint library]

* licensed under the
https://www.gnu.org/licenses/agpl-3.0.html[GNU _Affero_ General Public License 3.0 or later].

Usage
-----
This is how to feed a puzzle to the solver:

--------------------------------------------------------------------------------
# cat examples/single_solution.txt
_ _ _ | _ 6 8 | _ 1 _
1 _ _ | _ _ _ | 7 _ _
_ 4 3 | 2 _ _ | 5 _ _
------+-------+------
3 _ _ | _ _ _ | 4 _ _
8 _ _ | _ _ _ | _ _ 9
_ _ 1 | _ _ _ | _ _ 6
------+-------+------
_ _ 6 | _ _ 4 | 8 5 _
_ _ 2 | _ _ _ | _ _ 7
_ 1 _ | 5 9 _ | _ _ _

# ./constraint-sudoku-solver examples/single_solution.txt
Trying to solve...

Solution:
2 7 5 | 9 6 8 | 3 1 4
1 8 9 | 4 3 5 | 7 6 2
6 4 3 | 2 7 1 | 5 9 8
------+-------+------
3 2 7 | 6 1 9 | 4 8 5
8 6 4 | 7 5 2 | 1 3 9
9 5 1 | 8 4 3 | 2 7 6
------+-------+------
7 9 6 | 3 2 4 | 8 5 1
5 3 2 | 1 8 6 | 9 4 7
4 1 8 | 5 9 7 | 6 2 3

Took 0.032 seconds to find.
Given problem IS a true Sokudo.
--------------------------------------------------------------------------------

For more options, check the `--help` output:

--------------------------------------------------------------------------------
# ./constraint-sudoku-solver --help
usage: constraint-sudoku-solver [-h] [--echo] [--duration SECONDS] FILE

positional arguments:
FILE file with puzzle to solve (see examples for puzzle
syntax)

optional arguments:
-h, --help show this help message and exit
--echo dump puzzle about to solve
--duration SECONDS seconds to stop searching for additional solutions after
(default: 0.1)
--------------------------------------------------------------------------------