Skip to main content

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

pysuso-0.3.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysuso-0.3.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file pysuso-0.3.1.tar.gz.

File metadata

  • Download URL: pysuso-0.3.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.13.2 CPython/3.10.12 Linux/6.5.0-1017-azure

File hashes

Hashes for pysuso-0.3.1.tar.gz
Algorithm Hash digest
SHA256 5880949ad0b3a52356a0baba6bad3c9a1ebc07e1ddc17ec9a8282b5134d9b216
MD5 40103c1c3ae87072b2de232b6a095576
BLAKE2b-256 343d9114d3ff0c13c04331ff0e3e9214c0841f5d7970b191cc4bd379aeb85d1d

See more details on using hashes here.

File details

Details for the file pysuso-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pysuso-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.13.2 CPython/3.10.12 Linux/6.5.0-1017-azure

File hashes

Hashes for pysuso-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eaab3556e217905ad1a7acbba86e4aecc5888fa55d0cf19fd06c26ba8c15ebe7
MD5 1fa398dbc815b09cd10a0fab7b289703
BLAKE2b-256 a8604b5b01ebcf646c648f7d3e84ffed414ad4f8748ba0af9f2db2302195f077

See more details on using hashes here.

Supported by

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