A Python Sudoku solver and generator
Project description
Sudoku-py
Overview
Sudoku-py allows you to represent Sudoku boards easily. While also giving you the ability to solve and generate your own Sudoku boards.
Examples
Generator Example
from sudoku_py import SudokuGenerator
sudokuGenerator = SudokuGenerator(board_size=9)
sudokuGenerator.generate(cells_to_remove=50, symmetry_removal=True)
print(sudokuGenerator)
0 0 0 | h 0 0 | d e 0
e 0 0 | 0 0 0 | 0 0 h
0 h 0 | b 0 0 | 0 0 0
---------------------
d b a | g h 0 | 0 0 e
0 e i | a 0 f | g d 0
c 0 0 | 0 b d | h a i
---------------------
0 0 0 | 0 0 b | 0 h 0
f 0 0 | 0 0 0 | 0 0 c
0 d h | 0 0 g | 0 0 0
sudokuGenerator.board_exchange_values({'a': 9, 'b': 8, 'c': 7, 'd': 6, 'e': 5, 'f': 4, 'g': 3, 'h': 2, 'i': 1})
print(sudokuGenerator)
0 0 0 | 2 0 0 | 6 5 0
5 0 0 | 0 0 0 | 0 0 2
0 2 0 | 8 0 0 | 0 0 0
---------------------
6 8 9 | 3 2 0 | 0 0 5
0 5 1 | 9 0 4 | 3 6 0
7 0 0 | 0 8 6 | 2 9 1
---------------------
0 0 0 | 0 0 8 | 0 2 0
4 0 0 | 0 0 0 | 0 0 7
0 6 2 | 0 0 3 | 0 0 0
Sudoku Board
from sudoku_py import Sudoku
Sudoku(board=[
[0,0,0,2,0,0,6,5,0],
[5,0,0,0,0,0,0,0,2],
[0,2,0,8,0,0,0,0,0],
[6,8,9,3,2,0,0,0,5],
[0,5,1,9,0,4,3,6,0],
[7,0,0,0,8,6,2,9,1],
[0,0,0,0,0,8,0,2,0],
[4,0,0,0,0,0,0,0,7],
[0,6,2,0,0,3,0,0,0]
])
print(sudoku)
0 0 0 | 2 0 0 | 6 5 0
5 0 0 | 0 0 0 | 0 0 2
0 2 0 | 8 0 0 | 0 0 0
---------------------
6 8 9 | 3 2 0 | 0 0 5
0 5 1 | 9 0 4 | 3 6 0
7 0 0 | 0 8 6 | 2 9 1
---------------------
0 0 0 | 0 0 8 | 0 2 0
4 0 0 | 0 0 0 | 0 0 7
0 6 2 | 0 0 3 | 0 0 0
sudoku.solve(solutions=1)
print(sudoku)
1 3 8 | 2 4 7 | 6 5 9
5 7 4 | 6 3 9 | 1 8 2
9 2 6 | 8 1 5 | 4 7 3
---------------------
6 8 9 | 3 2 1 | 7 4 5
2 5 1 | 9 7 4 | 3 6 8
7 4 3 | 5 8 6 | 2 9 1
---------------------
3 1 7 | 4 5 8 | 9 2 6
4 9 5 | 1 6 2 | 8 3 7
8 6 2 | 7 9 3 | 5 1 4
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
sudoku_py-1.0.0.tar.gz
(3.8 kB
view details)
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 sudoku_py-1.0.0.tar.gz.
File metadata
- Download URL: sudoku_py-1.0.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17e9eeabc4425cccb59df51e97f7189adcd15f513029d5f770e24e5fae6acfd6
|
|
| MD5 |
e5051833f0179236914586421120d656
|
|
| BLAKE2b-256 |
3bc41ce8bb10cc0a54958c47dbdf138e0c26409f96725b471a44a24a27329a19
|
File details
Details for the file sudoku_py-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sudoku_py-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ceb11fe8cfdb02c905195a931c49a2539101e3335f50e3a423d228f2350dcb7
|
|
| MD5 |
69b12429abe578ce6410c1ad86d2ee02
|
|
| BLAKE2b-256 |
08283c176b49be651759079478873239e4ba4296a28bba83e5c1f38cf9c9c5d0
|