Solve sudoku using an 'exact cover' algorithm.
Project description
xudoku - Solve sudoku using an 'exact cover' algorithm
This is the sudoku code from @moygit's project 'exact_cover_np'.
The package is maintained by me, @jwg4.
I separated the code for the 'exact cover' algorithm (now available at https://github.com/jwg4/exact_cover) from the sudoku code and created this package. At that package you can find more info about the exact cover algorithm, which can be used for lots of combinatoric problems.
How to use the package
>>> import xudoku
>>> s = xudoku.Sudoku(9)
>>> s.read("tests/files/insight.csv")
>>> sol = s.solve()
>>> sol._sudo.tolist()
[[1, 3, 5, 2, 9, 7, 8, 6, 4], [9, 8, 2, 4, 1, 6, 7, 5, 3], [7, 6, 4, 3, 8, 5, 1, 9, 2], [2, 1, 8, 7, 3, 9, 6, 4, 5], [5, 9, 7, 8, 6, 4, 2, 3, 1], [6, 4, 3, 1, 5, 2, 9, 7, 8], [4, 2, 6, 5, 7, 1, 3, 8, 9], [3, 5, 9, 6, 2, 8, 4, 1, 7], [8, 7, 1, 9, 4, 3, 5, 2, 6]]
>>> s._hardness
'Easy'
Currently the puzzle data can only be read from CSV. You could use io.StringIO, which turns a string into a file-like object, if you want to generate your sudoku puzzle in code.
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
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 xudoku-1.0.0.tar.gz.
File metadata
- Download URL: xudoku-1.0.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.8.8 Linux/5.4.0-1040-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78a5c4960f4aa3e2ca2e50addb710f7f909d142c4a1c9c5029d5a32e3c98067b
|
|
| MD5 |
f15b7dcd478d99879a63239b2f19432a
|
|
| BLAKE2b-256 |
db49ad5d7271541c00c2413dca0d27d9eadf5dfc7f137a0cc36eb0aa8bba9656
|
File details
Details for the file xudoku-1.0.0-py3-none-any.whl.
File metadata
- Download URL: xudoku-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.8.8 Linux/5.4.0-1040-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c9c41f211fb76c21108e6aa5616b3b9d87bd52d6abdcb661a09a252f840fe1b
|
|
| MD5 |
cec978534dd603860ac2535c5ad9b022
|
|
| BLAKE2b-256 |
05fd0f26ea4c79308056ed7b5292e2f3ff587b025892dfbbe61285f0a18b9101
|