Sudoku sovler written in Python
Project description
PySuSo
PySuSo is a library for solving Sudoku puzzels with Python.
What does PySuSo provide
PySuSo provides a brute force backtracking solver for Sudoku puzzels. In addition to the solver a board representing the Sudoku puzzel is provided.
Installation
PySuSo is available on PyPi as pysuso. To install with pip run:
pip install pysuso
Quick start
Create a board using one of the provided methods on the Board class. See the documentation for an overview off all
the methods.
board = Board.from_list(
[
0, 5, 0, 7, 0, 3, 0, 6, 0,
0, 0, 7, 0, 0, 0, 8, 0, 0,
0, 0, 0, 8, 1, 6, 0, 0, 0,
0, 0, 0, 0, 3, 0, 0, 0, 0,
0, 0, 5, 0, 0, 0, 1, 0, 0,
7, 3, 0, 0, 4, 0, 0, 8, 6,
9, 0, 6, 0, 0, 0, 2, 0, 4,
8, 4, 0, 5, 7, 2, 0, 9, 3,
0, 0, 0, 4, 0, 9, 0, 0, 0
]
)
Create a solver providing the board:
solver = BasicSolver(board)
Call the solve method to search for a valid solution:
solver.solve()
Full example including imports:
from pysuso.boards import Board
from pysuso.solvers import BasicSolver
board = Board.from_list(
[
0, 5, 0, 7, 0, 3, 0, 6, 0,
0, 0, 7, 0, 0, 0, 8, 0, 0,
0, 0, 0, 8, 1, 6, 0, 0, 0,
0, 0, 0, 0, 3, 0, 0, 0, 0,
0, 0, 5, 0, 0, 0, 1, 0, 0,
7, 3, 0, 0, 4, 0, 0, 8, 6,
9, 0, 6, 0, 0, 0, 2, 0, 4,
8, 4, 0, 5, 7, 2, 0, 9, 3,
0, 0, 0, 4, 0, 9, 0, 0, 0
]
)
solver = BasicSolver(board)
solution = solver.solve()
print(solution)
Documentation
Full documentation is available at PySuSo Documentation.
Additional remarks
The tests for the solver are based on Sudokus found in the Sudoku Exchange Puzzle Bank.
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
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 pysuso-0.1.0.tar.gz.
File metadata
- Download URL: pysuso-0.1.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.12.4 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64ca4c97e8530f085fa1221de215f57ee05e3417d4620833b7f15201db1f0210
|
|
| MD5 |
0769ebb33bc502e739326da54a9352a3
|
|
| BLAKE2b-256 |
9e779eb3d45dfb9c162874b97c353e608c94ac25be232fbc9f2c67097136c43f
|
File details
Details for the file pysuso-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pysuso-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.12.4 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ced741f5314a479d102ca4b7569dd4ba74dc2551a6efb80c91c924a60e74c41f
|
|
| MD5 |
aaad090d772e1d962994a4cc6a317a9c
|
|
| BLAKE2b-256 |
6adf6c08d7006902895864972b0240ce9e93f735b877fe04917b9e5a85fffca4
|