Skip to main content

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.

Release files for sudoku-solver 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sudoku-solver 0.2
File Size Uploaded
sudoku-solver-0.2.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sudoku-solver 0.2
File Interpreter ABI Platform
sudoku_solver-0.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 39.5 kB

Release files / sudoku-solver-0.2.tar.gz

Download URL sudoku-solver-0.2.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c68d6bc6a349d36494cf5e428ef8a63192eeae2a2b08cff5af29acd655891518
BLAKE2b-256 checksum
How to use checksums
656b1cba561246be959be3829e9571c713eff0406422d21ce8d288b074c1ba74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / sudoku_solver-0.2-py2.py3-none-any.whl

Download URL sudoku_solver-0.2-py2.py3-none-any.whl
Size 24.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1d066e7c536b1acb61b19687af6f4cb9992b94ec9a4cd557de1008ceb41878ab
BLAKE2b-256 checksum
How to use checksums
04938f9287f547eda9b1930d9a173ea0a876a3fc3749fa84f9c938b13ff8ae71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page