Integer partitions with an optional max length
Project description
Restricted Partition
A restricted partition is the subset of an integer partition with only partitions at or below a certain length.
from restricted_partition import iter_partition
iter_partition(5)
# [1, 1, 1, 1, 1]
# [1, 1, 1, 2]
# [1, 1, 3]
# [1, 2, 2]
# [1, 4]
# [2, 3]
# [5]
iter_partition(5, 3)
# [1, 1, 3]
# [1, 2, 2]
# [1, 4]
# [2, 3]
# [5]
Uses the accel_asc algorithm (thank you, Jerome Kelleher), so it is pretty speedy in pure Python.
I found the algorithm at https://jeromekelleher.net/generating-integer-partitions.html.
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
Close
Hashes for restricted_partition-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0de4101cd3d6671e8959d7b9e34df91235c6699633c96999b81d22b2cb158731 |
|
MD5 | 0537432443e7e06bca6119a3b4d11973 |
|
BLAKE2b-256 | 27862e9430384b18e15b21ce4f1e220c3b45976086b413e04f25f6b608c5f61f |
Close
Hashes for restricted_partition-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c8ee57e0ba3118c12e3862fcf2e8a7ff57fff433c7e1b83b6085ca41d25d74e |
|
MD5 | 5c30a384d109800b7da0b09c2f0f0764 |
|
BLAKE2b-256 | cb2e85a717c8be1dd38321c76cab4404aeca49bc80b7a30887aec05d12a9b4f3 |