exact cover in Python/numba using algorithm X
an implementation of Donald Knuth's Dancing Links algorithm X in Python / numba
Usage
pip install exact_cover_py
from exact_cover_py import exact_covers
problem = np.array([
[1, 0, 0, 1, 0, 0, 1],
[1, 0, 0, 1, 0, 0, 0], # <--
[0, 0, 0, 1, 1, 0, 1],
[0, 0, 1, 0, 1, 1, 0], # <--
[0, 1, 1, 0, 0, 0, 1],
[0, 1, 1, 0, 0, 1, 1], # <--
[0, 1, 0, 0, 0, 0, 1],
])
# exact_covers returns a generator of solutions
# one solution
print(next(exact_covers(problem)))
[1, 5, 3]
# all solutions
print(list(exact_covers(problem)))
[[1, 5, 3]]
# number of solutions
def mylen(iterable):
return sum(map(lambda x: 1, iterable))
print(mylen(exact_covers(problem)))
2
Metadata
Release files for exact-cover-py 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| exact_cover_py-0.1.2.tar.gz | 60.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| exact_cover_py-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 118.1 kB
Release files / exact_cover_py-0.1.2.tar.gz
| Download URL | exact_cover_py-0.1.2.tar.gz |
|---|---|
| Size | 60.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52e8146f99c9116d80d20d8caff2a7e1281900bbb00afa5257c5068985e5c7bc
|
|
BLAKE2b-256 checksum How to use checksums |
514a31ce33da7c723df17945b40784afaca2cb5bd190c69394c021395ab9b527
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.1
|
Release files / exact_cover_py-0.1.2-py3-none-any.whl
| Download URL | exact_cover_py-0.1.2-py3-none-any.whl |
|---|---|
| Size | 57.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26548ddeca50753064bea8f42f0839d13d7472ba981e3d561a7d0995fb938239
|
|
BLAKE2b-256 checksum How to use checksums |
76ad831f297e80ac36467595f91180acdac541e4c4a50c4e5c861641330cbfe7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.1
|