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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d961329653d00ed30e14ba684d2af254f6bef4fbc655233e531ef03a81c6d83 |
|
MD5 | 7b8bf21ebac9a84597a8dc0f59d4ef46 |
|
BLAKE2b-256 | 5923099b99ec17641bdbc1ceb64a51778c561d95c773989ab0779bfd89e7089c |
Close
Hashes for restricted_partition-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43e02a991e030cecdc6565f849171a70c9e54e8b445f8e200554c050f7be75c2 |
|
MD5 | 5ac4ee556da7b8e306720cac5c5300c9 |
|
BLAKE2b-256 | 67f04b6e15bac77158bf932484efe0fb39e66d80041191c664ba11a739d80af5 |