Skip to main content

exact cover in Python

an implementation of Donald Knuth's Dancing Links algorithm in pure Python

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]]

Development

# build and install locally with tests dependencies
pip install -e .[tests]

pytest

Building

pip install build
python -m build

Publishing

pip install twine
twine upload dist/*

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exact_cover_py-0.0.1.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

exact_cover_py-0.0.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file exact_cover_py-0.0.1.tar.gz.

File metadata

  • Download URL: exact_cover_py-0.0.1.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for exact_cover_py-0.0.1.tar.gz
Algorithm Hash digest
SHA256 80a88c7a99d676cb4428729e2e45df49edbf7fe684afab548de749cc9e79a0fb
MD5 7f2218ab554c979c8f30b0d7c2f12e87
BLAKE2b-256 02d241d0b724c7d4700ec8af318ad23bb5719a124bcee3794e069d28c4cbf361

See more details on using hashes here.

File details

Details for the file exact_cover_py-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: exact_cover_py-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for exact_cover_py-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c80cc65adcdb3a6ffba51c85a1a6a206793e552a257dd3e5cd7c50ad7e247ef
MD5 523e5e8b75a394982687018a3807c7e1
BLAKE2b-256 a7d5026622897051611655b2488ae885ad36eabd7935508c622a8df6e8575ec9

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.2

2 files

0.1.1

2 files

0.0.4

2 files

0.0.3

2 files

This release

0.0.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page