Skip to main content

Library and scripts for solving Sudoku puzzles.

Project description

Library for solving Sudoku puzzles step by step, in an human manner.

Several scripts are provided to solve directly some grids.

Scripts

sudoku_solver

Usage: sudoku_indexes [options] source

Script for solving Sudoku puzzles in an human manner, applying some advanced strategies for solving grids.

If a puzzle cannot be solved with the strategies bundled in the package, the resolution of the puzzle is done by a backtracking method.

Use the --nobacktracking option to disable the backtracking method.

Increasing the verbosity level at 3 (-vvv) will display step by step the solving process.

sudoku_backtrack

Usage: sudoku_backtrack [options] source

Script for solving Sudoku puzzles with the backtracking method only.

Use the --nopreprocessing option to disable the preprocessing methods applied to reduces the number of candidates.

This option is useful on small grids where optimisations are not really needed, but disabling the processings methods on large grid will increase the resolution time.

sudoku_indexes

Usage: sudoku_indexes

Display the cells’s indexes of a Sudoku puzzle, like they are used in the package. Very usefull when developing.

Grid files

The files handled by the solvers have to respect some rules to be processed.

  1. The grid file should contains only digits and the free_char character. By default the free_char is represented by a dot ‘.’

  2. Everything else will be ignored by default

  3. A 0 character is the same as the free_char.

  4. You can put comments on your grids if a line starts with the # character.

  5. If the grid has a size different than 81, the grid file will not be considered as valid.

Example 1

123.56.89578139624496872153952381467641.97835387564291719623548864915372235748916

Example 2

004000620760100800000000107000901300230406091001302000903000000006005013042000700

Example 3

1638.5.7.
..8.4..65
..5..7..8
45..82.39
3.1....4.
7........
839.5....
6.42..59.
....93.81

Example 4

3 2 9 | 4 1 . | 7 . .
. . . | . . . | 4 . .
. . 5 | . 2 . | . . .
---------------------
5 . . | . . . | 3 . 6
. 6 . | 7 . 3 | . 9 .
8 . 7 | . . . | . . 2
---------------------
. . . | . 4 . | 8 . .
. . 6 | . . . | . . .
. . 3 | . 7 2 | 9 5 1

Take a look in the datas folder for more examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sudoku-solver-0.2.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

sudoku_solver-0.2-py2.py3-none-any.whl (24.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file sudoku-solver-0.2.tar.gz.

File metadata

  • Download URL: sudoku-solver-0.2.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sudoku-solver-0.2.tar.gz
Algorithm Hash digest
SHA256 c68d6bc6a349d36494cf5e428ef8a63192eeae2a2b08cff5af29acd655891518
MD5 94969b90e8be6b9d086f8dacd9221170
BLAKE2b-256 656b1cba561246be959be3829e9571c713eff0406422d21ce8d288b074c1ba74

See more details on using hashes here.

File details

Details for the file sudoku_solver-0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sudoku_solver-0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1d066e7c536b1acb61b19687af6f4cb9992b94ec9a4cd557de1008ceb41878ab
MD5 be7bae3f64edca3f82a6dccce6aec641
BLAKE2b-256 04938f9287f547eda9b1930d9a173ea0a876a3fc3749fa84f9c938b13ff8ae71

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page