Skip to main content

A simple Python package that generates and solves m x n Sudoku puzzles.

Project description

sudoku-engine

A simple Python package that generates and solves m x n Sudoku puzzles. A modified version of py-sudoku, Built by jeffsieu. This library serves primarily as the backend for Sudoku, but can be used as a standalone Sudoku library.

Install

# Python 3
pip3 install sudoku-engine

Usage

Classic Sudoku

from sudoku import ClassicSudoku

puzzle = ClassicSudoku(size=9)
print("Puzzle:")
print(puzzle)

solution = puzzle.solve()
print("Solved:")
print(solution)

Diagonal Sudoku

from sudoku import DiagonalSudoku

puzzle = DiagonalSudoku(size=9)
solution = puzzle.solve()

Generating Puzzles

from sudoku.base_sudoku import PuzzleGenerator
from sudoku import ClassicSudoku

puzzle = PuzzleGenerator.make_puzzle(
    sudoku_cls=ClassicSudoku,
    size=9,
    difficulty=0.5,
    ensure_unique=True
)
print(puzzle)

If you wish to raise an UnsolvableSudoku error when the board is invalid pass a raising=True parameter:

puzzle.solve(raising=True)

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

sudoku_engine-2.0.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

sudoku_engine-2.0.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file sudoku_engine-2.0.0.tar.gz.

File metadata

  • Download URL: sudoku_engine-2.0.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for sudoku_engine-2.0.0.tar.gz
Algorithm Hash digest
SHA256 e528f17b3b4294bfe32f76e1086d4ba17cafd0ea760ee036daa0cacd7d976b43
MD5 df7044b46dfddad39bc426c03e7ff4ba
BLAKE2b-256 cd635d9664c38b611d414a0f1c1db13410829c9c926ba83cd373715fd04111ac

See more details on using hashes here.

File details

Details for the file sudoku_engine-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: sudoku_engine-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for sudoku_engine-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a722ccf676c71df2dba5e69f65d725c63b38d0b54d7ed915a7325ea0066656bc
MD5 716fe08cd4596a2481779a72963a5eba
BLAKE2b-256 0c4fe5de816646174cdd8c5db5e2422d4b3eb7cd38bcc398aa0e57047ece6db8

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