A sudoku puzzle solver and generator
Project description
Sudokugen
Package for solving and generating sudoku puzzles!
Setup
$ pip install sudokugen
or
$ git clone https://github.com/g-k-l/sudoku-gen.git
$ cd sudoku-gen
$ pip install .
Usage
Solver
>>> from sudokugen.solver import solve
>>> my_puzzle = [[0, 3, 6, 8, 9, 2, 7, 1, 5],
[5, 0, 2, 0, 7, 1, 9, 0, 3],
[9, 0, 7, 5, 6, 3, 4, 8, 2],
[0, 4, 3, 1, 5, 8, 2, 0, 7],
[8, 5, 9, 6, 0, 7, 1, 3, 0],
[7, 2, 0, 9, 3, 4, 8, 5, 6],
[0, 0, 0, 2, 8, 6, 5, 0, 1],
[0, 0, 0, 3, 1, 0, 0, 4, 9],
[0, 0, 0, 7, 4, 9, 3, 2, 8]]
>>> solution = solve(my_puzzle)
And solution looks like:
[[4, 3, 6, 8, 9, 2, 7, 1, 5],
[5, 8, 2, 4, 7, 1, 9, 6, 3],
[9, 1, 7, 5, 6, 3, 4, 8, 2],
[6, 4, 3, 1, 5, 8, 2, 9, 7],
[8, 5, 9, 6, 2, 7, 1, 3, 4],
[7, 2, 1, 9, 3, 4, 8, 5, 6],
[3, 9, 4, 2, 8, 6, 5, 7, 1],
[2, 7, 8, 3, 1, 5, 6, 4, 9],
[1, 6, 5, 7, 4, 9, 3, 2, 8]]
Puzzle Generator
from sudokugen.generator import generate, Difficulty
new_puzzle = generate(difficulty=Difficulty.MEDIUM)
Difficulty refers to the number of cells which have values assigned in the beginning. For MEDIUM
, this number is 24
.
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
sudokugen-0.2.1.tar.gz
(6.2 kB
view hashes)
Built Distribution
sudokugen-0.2.1-py3-none-any.whl
(20.0 kB
view hashes)
Close
Hashes for sudokugen-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fec4e67f3a687fb3081e6a4b6ea1c258a80bc7940ca4e3cf150017e541efc18f |
|
MD5 | db33e4474a52c1900311169c07bf3471 |
|
BLAKE2b-256 | 70e803a7b4a788465b02c2f10a93c87cbc7d321fc8a62144af806d939566fbf4 |