Sudoku solver,that solves sudoku puzzles using constraint programming
Project description
A sudoku solver that solves the puzzle using constraint programming
Installation
Installation through pip:
pip install kudosudoku
Installation through cloning:
git clone https://github.com/Varshneyabhushan/kudoSudoku.git
cd kudoSudoku
python setup.py install
Usage
import class sudoku from the module.
pass puzzle to be solved as list of lists
sudoku has a method called solve( ) that returns the solved puzzle
- output will be an object with the following keys
done : “describing status if its done or not”
iterations : “number of times puzzle is re visited”
guesses : “number of places where it had to guess”
timeTaken : “Time taken to conclude”
solution : “Final answer(will be a list of list of integers)”
Example
To solve this sudoku
Input has to be:
[[0,2,4,0],[1,0,0,3],[4,0,0,2],[0,1,3,0]]
As python language is case sensitive,you have to import kudoSudoku,not kudosudoku.
from kudoSudoku import sudoku
puzzle = [[0,2,4,0],[1,0,0,3],[4,0,0,2],[0,1,3,0]]
table = sudoku(puzzle)
result = table.solve()
print(result)
Output:
{'done': True, 'iterations': 2, 'guesses': 0, 'timeTaken': 0.0013199988754573474, 'solution': [[3, 2, 4, 1], [1, 4, 2, 3], [4, 3, 1, 2], [2, 1, 3, 4]]}
2X2 sudoku is taken just to demonstrate. It works for any nxn sudoku
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
File details
Details for the file kudosudoku-1.0.2.tar.gz.
File metadata
- Download URL: kudosudoku-1.0.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b9f3bca03f9c18290dee3a7b996918892af497c17f17977a22fa8a026561aef
|
|
| MD5 |
2c8328400b926aa07aa2ac8463b8682f
|
|
| BLAKE2b-256 |
7791ae255806f02ba7c9db5ac62e2ae5ccca65fd139eaaae5a8cf2e618120e48
|