exact cover samples
contains some exact cover samples together with their solutions.
installation
pip install exact-cover-samples
usage
problems
from exact_cover_samples import problems
problems is a dictionary with the following structure:
{ "shortname": function, ... }
where shortname is a string and function is a function that in turn returns
a dictionary with the following structure:
{
"shortname": str, # short name of the problem
"name": str, # long name of the problem
"data": np.ndarray, # of ndim=2 and dtype=bool
"solutions": list[list[int]] # each solution is a list of indices in data
}
in some cases solutions is an nd-array too - see below how to canonicalize for
comparing solutions.
summary
you can display a summary of the available problems by running the following code:
from exact_cover_samples import summary
summary()
will show all known problems
# you can also filter a bit
summary("pent")
->
the problems whose name contains 'pent' are:
===================== p3x20 ======================
size = (1236, 72), 8 solutions full_name=pentominos-3-20
===================== p4x15 ======================
size = (1696, 72), 1472 solutions full_name=pentominos-4-15
canonical representation
from exact_cover_samples import problems, canonical
p = problems["knuth2000"]()
s = p["solutions"]
type(s)
-> list
type(s[0])
-> tuple
type(canonical(s))
-> set
p = problems["p8x8"]()
s = p["solutions"]
type(s)
-> numpy.ndarray
type(canonical(s))
-> set
so that as long as your code produces solutions as an iterable of iterables,
you should be able to use canonical to compare them like so
# import this module
import exact_cover_samples as ecs
# import a solver module
from exact_cover_py import exact_covers
# get a problem
p = ecs.problems["knuth2000"]()
# get the expected solutions
expected = p["solutions"]
# get the computed solutions
computed = exact_covers(p["data"])
# compare them
assert ecs.canonical(expected) == ecs.canonical(computed)
and so you can write a very decent test suite for your exact cover solver by
simply iterating over the problems in problems and comparing the expected
solutions with the computed ones.
Metadata
Release files for exact-cover-samples 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| exact_cover_samples-0.0.8.tar.gz | 11.7 MB | Without provenance | Details for exact_cover_samples-0.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| exact_cover_samples-0.0.8-py3-none-any.whl | Python 3 | none | any | Details for exact_cover_samples-0.0.8-py3-none-any.whl |
Total release size: 12.3 MB
Release files / exact_cover_samples-0.0.8.tar.gz
| Download URL | exact_cover_samples-0.0.8.tar.gz |
|---|---|
| Size | 11.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4b5561f415c4ee71489154c6d43bcf3c1d5a89d95fddf1f884ebb3e3195285d
|
|
BLAKE2b-256 checksum How to use checksums |
9ac1d700df5b0739fc830784574996184408f5b0ce953b26aa0c475a99590b1f
|
| 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_samples-0.0.8-py3-none-any.whl
| Download URL | exact_cover_samples-0.0.8-py3-none-any.whl |
|---|---|
| Size | 637.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d34b0c7d481aff8aed2a5104c7c74ce0199aa123796c6751b8bcf005b10773db
|
|
BLAKE2b-256 checksum How to use checksums |
de6b438c4152d9e456e4b6d1a0ca82d1f00c60011bbcb1da444d45c7bc8865db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.1
|
Security for exact-cover-samples 0.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.