combinadics
Combinatorial system of degree k ranking and unranking is a standalone simple (not necessarily the most efficient) module to compute the combinadics of a natural number (a.k.a unranking) and the inverse operation (a.k.a ranking)
Code is a commented python implementation of James McCaffrey' concepts of
- Generating combinations through generating combination successors.
- Calculating an arbitrary mathematical combination from a given lexicographical index (unranking) and, not explicit in McCaffrey' article,
- Given a combination, calculate its lexicographical index (ranking).
Note that in the original article the author claims that the combinations he presents are in lexicographic order, which is not true. However, both his discussion and code are correct.
Installation
pip install combinadics
Use
from combinadics import Choose, Combination
combinations = Choose(5,3)
print("Choose(5,3) results in {} combinations".format(combinations))
combination = Combination(5,3)
print("Combination(5, 3) is initially {}".format(Combination(5,3)))
print("The lexicographic successor of combination {} is {}".format(
combination, combination.Successor()
))
print("Now we set the combination data to be {0 3 4}")
combination.data = [0, 3, 4]
print("The lexicographic successor of combination {} is {}".format(
combination, combination.Successor()
))
combination = Combination(5, 3, [2, 3, 4])
print("The rank of combination {} is {}".format(
combination, combination.Rank()
))
combination = Combination(5, 3)
position = 3
print("In position {} we find combination {}".format(
position, combination.Element(position)
))
outputs
Choose(5,3) results in 10 combinations
Combination(5, 3) is initially {0 1 2}
The lexicographic successor of combination {0 1 2} is {0 1 3}
Now we set the combination data to be {0 3 4}
The lexicographic successor of combination {0 3 4} is {1 2 3}
The rank of combination {2 3 4} is 9
In position 3 we find combination {0 2 3}
Metadata
Release files for combinadics 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| combinadics-0.0.3.tar.gz | 6.1 kB | Without provenance | Details for combinadics-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| combinadics-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for combinadics-0.0.3-py3-none-any.whl |
Total release size: 13.4 kB
Release files / combinadics-0.0.3.tar.gz
| Download URL | combinadics-0.0.3.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0856ed0e071bac52846249de8154525196dcfa34b438218de77658040500143e
|
|
BLAKE2b-256 checksum How to use checksums |
bded3415e373da1861ba736814f69ada7f9e1ffda6cc19fa1d00c10fb0964ce1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.10
|
Release files / combinadics-0.0.3-py3-none-any.whl
| Download URL | combinadics-0.0.3-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3aa20c9ae8d0868844fe56c6cc8246cd86006f1f9db4d5e9d7213293dd15fb3
|
|
BLAKE2b-256 checksum How to use checksums |
9e70e9770e4ebaad0eed9e389a8f6f6b80591f1fa7377f893ef03b1c67d69a80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.10
|
Security for combinadics 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.