KombiN - Python 3 Library
KombiN is a Python library for bijectively mapping all ordered pairs $(a_i, b_j)$ from two finite sets A and B into a single linear index. Pairs are ordered by ascending weight (sum of indices) using a three-region zig-zag algorithm, enabling O(1) bidirectional lookups between pairs and indices.
Installation
Install from PyPI:
pip install kombin-algo-pranavpatel-ca
Usage
Suppose set A has 100 elements and set B has 80 elements, both using zero-based indexing:
from kombin import Table
# Initialize Table for sets A (100 elements) and B (80 elements), zero-based indexing
myObj = Table(100, 80, True)
# Get index for combination pair (ai: 46, bi: 72)
index = myObj.GetIndexOfElements(46, 72)
# Get combination pair from index value
ai, bi = myObj.GetElementsAtIndex(index)
API Reference
Table Class
Constructor:
Table(lengthOfA: int, lengthOfB: int, zeroBasedIndex: bool)
lengthOfA: Number of elements in set A.lengthOfB: Number of elements in set B.zeroBasedIndex:Truefor zero-based,Falsefor one-based indexing.
Methods:
-
GetIndexOfElements(ai: int, bi: int) -> int
Returns the unique index for the pair(ai, bi). -
GetElementsAtIndex(index: int) -> Tuple[int, int]
Returns the pair(ai, bi)for the given index.
Example: Enumerate All Pairs by Weight
table = Table(3, 3, False)
for i in range(1, 10):
ai, bi = table.GetElementsAtIndex(i)
print(f"{i}: ({ai}, {bi})")
Edge Cases & Error Handling
- Raises
ValueErrorfor invalid indices or set sizes. - Large
lengthOfAorlengthOfBmay cause integer overflows in some environments.
License
MIT License. See LICENSE
Metadata
Release files for kombin-algo-pranavpatel-ca 1.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 |
|---|---|---|---|---|
| kombin_algo_pranavpatel_ca-1.0.3.tar.gz | 5.5 kB | Without provenance | Details for kombin_algo_pranavpatel_ca-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kombin_algo_pranavpatel_ca-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for kombin_algo_pranavpatel_ca-1.0.3-py3-none-any.whl |
Total release size: 10.4 kB
Security for kombin-algo-pranavpatel-ca 1.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.