Sudoku solver that will use successively more advanced techniques to solve the puzzle.
Project description
Sudoku solver
This is a sudoku solver that helps you solve sudoku puzzles by showing you the easiest possible strategy required to solve the puzzle.
Setup
Install the package:
pip install sudoku-solver-tim
Usage
from sudoku_solver_tim import Puzzle
grid = [
[0, 0, 1, 9, 5, 7, 0, 6, 3],
[0, 0, 0, 8, 0, 6, 0, 7, 0],
[7, 6, 9, 1, 3, 0, 8, 0, 5],
[0, 0, 7, 2, 6, 1, 3, 5, 0],
[3, 1, 2, 4, 9, 5, 7, 8, 6],
[0, 5, 6, 3, 7, 8, 0, 0, 0],
[1, 0, 8, 6, 0, 9, 5, 0, 7],
[0, 9, 0, 7, 1, 0, 6, 0, 8],
[6, 7, 4, 5, 8, 3, 0, 0, 0],
]
puzzle = Puzzle(grid)
# Find the easiest strategy to make progress (remove a pencil mark)
puzzle.solve_step()
#> Made progress using candidate_lines
# Solve the puzzle using all strategies
puzzle.solve()
puzzle.strategies_used
# {'Candidate Lines', 'Single Candidate'}
puzzle
#> ┏━━━┯━━━┯━━━┓ ┏━━━┯━━━┯━━━┓ ┏━━━┯━━━┯━━━┓
#> ┃ 2 │ 8 │ 1 ┃ ┃ 9 │ 5 │ 7 ┃ ┃ 4 │ 6 │ 3 ┃
#> ┠───┼───┼───┨ ┠───┼───┼───┨ ┠───┼───┼───┨
#> ┃ 4 │ 3 │ 5 ┃ ┃ 8 │ 2 │ 6 ┃ ┃ 9 │ 7 │ 1 ┃
#> ┠───┼───┼───┨ ┠───┼───┼───┨ ┠───┼───┼───┨
#> ┃ 7 │ 6 │ 9 ┃ ┃ 1 │ 3 │ 4 ┃ ┃ 8 │ 2 │ 5 ┃
#> ┗━━━┷━━━┷━━━┛ ┗━━━┷━━━┷━━━┛ ┗━━━┷━━━┷━━━┛
#> ┏━━━┯━━━┯━━━┓ ┏━━━┯━━━┯━━━┓ ┏━━━┯━━━┯━━━┓
#> ┃ 8 │ 4 │ 7 ┃ ┃ 2 │ 6 │ 1 ┃ ┃ 3 │ 5 │ 9 ┃
#> ┠───┼───┼───┨ ┠───┼───┼───┨ ┠───┼───┼───┨
#> ┃ 3 │ 1 │ 2 ┃ ┃ 4 │ 9 │ 5 ┃ ┃ 7 │ 8 │ 6 ┃
#> ┠───┼───┼───┨ ┠───┼───┼───┨ ┠───┼───┼───┨
#> ┃ 9 │ 5 │ 6 ┃ ┃ 3 │ 7 │ 8 ┃ ┃ 2 │ 1 │ 4 ┃
#> ┗━━━┷━━━┷━━━┛ ┗━━━┷━━━┷━━━┛ ┗━━━┷━━━┷━━━┛
#> ┏━━━┯━━━┯━━━┓ ┏━━━┯━━━┯━━━┓ ┏━━━┯━━━┯━━━┓
#> ┃ 1 │ 2 │ 8 ┃ ┃ 6 │ 4 │ 9 ┃ ┃ 5 │ 3 │ 7 ┃
#> ┠───┼───┼───┨ ┠───┼───┼───┨ ┠───┼───┼───┨
#> ┃ 5 │ 9 │ 3 ┃ ┃ 7 │ 1 │ 2 ┃ ┃ 6 │ 4 │ 8 ┃
#> ┠───┼───┼───┨ ┠───┼───┼───┨ ┠───┼───┼───┨
#> ┃ 6 │ 7 │ 4 ┃ ┃ 5 │ 8 │ 3 ┃ ┃ 1 │ 9 │ 2 ┃
#> ┗━━━┷━━━┷━━━┛ ┗━━━┷━━━┷━━━┛ ┗━━━┷━━━┷━━━┛
Backlog
We could add additional strategies to the solver.
- Y-wings https://sudoku.com/sudoku-rules/y-wing/
- Forcing Chains: https://www.sudokuoftheday.com/techniques/forcing-chains
- Explicit separate the Swordfish-3 and Swordfish-4 strategies, as Swordfish-4 is sometimes called "Jellyfish"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sudoku_solver_tim-0.1.0.tar.gz.
File metadata
- Download URL: sudoku_solver_tim-0.1.0.tar.gz
- Upload date:
- Size: 90.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d497cb5772520b0e50cd300a2a2be3468722fdfed0b438ac21ec659e90ba53a6
|
|
| MD5 |
cab7319b270a680549db2c7a898881d3
|
|
| BLAKE2b-256 |
3d5023e9a612962a00457e904dc717839e537afc2459b3eac12b0fbab92225b8
|
Provenance
The following attestation bundles were made for sudoku_solver_tim-0.1.0.tar.gz:
Publisher:
publish_to_pypi.yml on timvink/sudoku-solver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sudoku_solver_tim-0.1.0.tar.gz -
Subject digest:
d497cb5772520b0e50cd300a2a2be3468722fdfed0b438ac21ec659e90ba53a6 - Sigstore transparency entry: 184775352
- Sigstore integration time:
-
Permalink:
timvink/sudoku-solver@73838deba37e04c4c4e965d65db28bea8d72bcd6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/timvink
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_to_pypi.yml@73838deba37e04c4c4e965d65db28bea8d72bcd6 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sudoku_solver_tim-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sudoku_solver_tim-0.1.0-py3-none-any.whl
- Upload date:
- Size: 36.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e1c0ce752a39b7b0be0aa8eec3c57a388fc51707ab7c3a74ec395fd4d1c2c6d
|
|
| MD5 |
541e5de87979dafc2db1cb25ac392fc8
|
|
| BLAKE2b-256 |
932e351d9a8ac79c8561d030fe4613eb44dcff24a3367fed10c48d4137418407
|
Provenance
The following attestation bundles were made for sudoku_solver_tim-0.1.0-py3-none-any.whl:
Publisher:
publish_to_pypi.yml on timvink/sudoku-solver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sudoku_solver_tim-0.1.0-py3-none-any.whl -
Subject digest:
4e1c0ce752a39b7b0be0aa8eec3c57a388fc51707ab7c3a74ec395fd4d1c2c6d - Sigstore transparency entry: 184775355
- Sigstore integration time:
-
Permalink:
timvink/sudoku-solver@73838deba37e04c4c4e965d65db28bea8d72bcd6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/timvink
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_to_pypi.yml@73838deba37e04c4c4e965d65db28bea8d72bcd6 -
Trigger Event:
workflow_dispatch
-
Statement type: