Sudoku solver with step-by-step guidance
Project description
Sudoku solver with step-by-step guidance
This lib is currently in pre-alpha phase, but already can solve some simple and medium level sudoku.
The following code displays all steps leading to solution:
from dokusan import entities, techniques
def list_steps(sudoku: entities.Sudoku):
all_techniques = (
techniques.LoneSingle,
techniques.HiddenSingle,
techniques.NakedPair,
techniques.NakedTriplet,
techniques.Omission,
techniques.XYWing,
techniques.UniqueRectangle,
)
i = 1
while not sudoku.is_solved() and i == 1:
i = 0
for technique in all_techniques:
try:
result = technique(sudoku).first()
except techniques.NotFound as exc:
continue
else:
sudoku.update_cells(result.changed_cells)
yield result
i = 1
break
_ = 0
sudoku = entities.Sudoku([
[_, _, _, _, 9, _, 1, _, _],
[_, _, _, _, _, 2, 3, _, _],
[_, _, 7, _, _, 1, 8, 2, 5],
[6, _, 4, _, 3, 8, 9, _, _],
[8, 1, _, _, _, _, _, _, _],
[_, _, 9, _, _, _, _, _, 8],
[1, 7, _, _, _, _, 6, _, _],
[9, _, _, _, 1, _, 7, 4, 3],
[4, _, 3, _, 6, _, _, _, 1],
])
for step in list_steps(sudoku):
print(step.combination)
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
dokusan-0.1.0a0.tar.gz
(17.9 kB
view details)
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
dokusan-0.1.0a0-py3-none-any.whl
(18.4 kB
view details)
File details
Details for the file dokusan-0.1.0a0.tar.gz.
File metadata
- Download URL: dokusan-0.1.0a0.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.8.0 Linux/5.0.0-1023-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22a2bed96aaa78c57be35a665b6c3b044df45545981ced9e1d1ba8f33f7a5053
|
|
| MD5 |
452bdd30a9e199403bfe1f182bcc91ef
|
|
| BLAKE2b-256 |
324bd64d550e696f178f9f3261576310faaca9c301cc3cc038fe3cbdba43a113
|
File details
Details for the file dokusan-0.1.0a0-py3-none-any.whl.
File metadata
- Download URL: dokusan-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.8.0 Linux/5.0.0-1023-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08f490ecf6296b1fdf0f221dc8a7d8d83db2013010630879edd5ddf2ecf5fc30
|
|
| MD5 |
009b0dae26186f87ead398a2eddfc51d
|
|
| BLAKE2b-256 |
026ff2dd40a15bee53d3d7fc4480b2b54c9ee2546165b036534e728c83565906
|