Generates partitions of a positive integer
Project description
partitions
In number theory and combinatorics, a partition of a positive integer n, also called an integer partition, is a way of writing n as a sum of positive integers.
For example, the partitions of 5:
5
4 + 1
3 + 1 + 1
2 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1
2 + 2 + 1
3 + 2
Setup and run
pip3 install partitions
To run on the command-line:
$ partitions 11
11
10 + 1
9 + 1 + 1
8 + 1 + 1 + 1
7 + 1 + 1 + 1 + 1
...
You can also use this in code:
from partitions import partitions
list(partitions(5)) # returns [(5,), (4, 1), (3, 1, 1), (2, 1, 1, 1), (1, 1, 1, 1, 1), (2, 2, 1), (3, 2)]
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 partitions-1.0.0.tar.gz.
File metadata
- Download URL: partitions-1.0.0.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.22.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41672fdd651560fb4b384695591873139fd04992379efe3a9da4a7c3b6c9f186
|
|
| MD5 |
49910a1277252dc2c7673c71db9948bf
|
|
| BLAKE2b-256 |
7d708ef40b0029a931be66f47419e3e5c48a97fdd421b429a7ea741fa3b67dd6
|
File details
Details for the file partitions-1.0.0-py3-none-any.whl.
File metadata
- Download URL: partitions-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.22.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c8f148191e333b3d97f176f94ed8cadc88c664122d7f3a82528fadcfe1c7d17
|
|
| MD5 |
079f2fffa5e918f4c32e3376869f531d
|
|
| BLAKE2b-256 |
0dd9523cd8498f01a9b638c0b139ca61dd762d8befd5a42c41b2034696ecc189
|