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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file restricted_partition-0.1.1.tar.gz.
File metadata
- Download URL: restricted_partition-0.1.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0de4101cd3d6671e8959d7b9e34df91235c6699633c96999b81d22b2cb158731
|
|
| MD5 |
0537432443e7e06bca6119a3b4d11973
|
|
| BLAKE2b-256 |
27862e9430384b18e15b21ce4f1e220c3b45976086b413e04f25f6b608c5f61f
|
File details
Details for the file restricted_partition-0.1.1-py3-none-any.whl.
File metadata
- Download URL: restricted_partition-0.1.1-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c8ee57e0ba3118c12e3862fcf2e8a7ff57fff433c7e1b83b6085ca41d25d74e
|
|
| MD5 |
5c30a384d109800b7da0b09c2f0f0764
|
|
| BLAKE2b-256 |
cb2e85a717c8be1dd38321c76cab4404aeca49bc80b7a30887aec05d12a9b4f3
|