Skip to main content

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


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 details)

Uploaded Source

Built Distribution

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

sudokugen-0.2.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file sudokugen-0.2.1.tar.gz.

File metadata

  • Download URL: sudokugen-0.2.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.9

File hashes

Hashes for sudokugen-0.2.1.tar.gz
Algorithm Hash digest
SHA256 27ab57d427516b49569ec0b9f0dfcedfb0016a40e168ba68b9fac24cb6109d92
MD5 27226c72af3e1f6c927adcb9b679c19a
BLAKE2b-256 8f2683e382e5328039a8b5e470caaa1776a6e0a312a744188c3bd89495ef56fc

See more details on using hashes here.

File details

Details for the file sudokugen-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: sudokugen-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.9

File hashes

Hashes for sudokugen-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fec4e67f3a687fb3081e6a4b6ea1c258a80bc7940ca4e3cf150017e541efc18f
MD5 db33e4474a52c1900311169c07bf3471
BLAKE2b-256 70e803a7b4a788465b02c2f10a93c87cbc7d321fc8a62144af806d939566fbf4

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