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.
Release files for xudoku 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| xudoku-1.0.0.tar.gz | 11.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xudoku-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.9 kB
Release files / xudoku-1.0.0.tar.gz
| Download URL | xudoku-1.0.0.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78a5c4960f4aa3e2ca2e50addb710f7f909d142c4a1c9c5029d5a32e3c98067b
|
|
BLAKE2b-256 checksum How to use checksums |
db49ad5d7271541c00c2413dca0d27d9eadf5dfc7f137a0cc36eb0aa8bba9656
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.5 CPython/3.8.8 Linux/5.4.0-1040-azure
|
Release files / xudoku-1.0.0-py3-none-any.whl
| Download URL | xudoku-1.0.0-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c9c41f211fb76c21108e6aa5616b3b9d87bd52d6abdcb661a09a252f840fe1b
|
|
BLAKE2b-256 checksum How to use checksums |
05fd0f26ea4c79308056ed7b5292e2f3ff587b025892dfbbe61285f0a18b9101
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.5 CPython/3.8.8 Linux/5.4.0-1040-azure
|