Skip to main content

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: True for zero-based, False for 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 ValueError for invalid indices or set sizes.
  • Large lengthOfA or lengthOfB may cause integer overflows in some environments.

License

MIT License. See LICENSE

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)

Source distribution for kombin-algo-pranavpatel-ca 1.0.3
File Size Uploaded
kombin_algo_pranavpatel_ca-1.0.3.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kombin-algo-pranavpatel-ca 1.0.3
File Interpreter ABI Platform
kombin_algo_pranavpatel_ca-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / kombin_algo_pranavpatel_ca-1.0.3.tar.gz

Download URL kombin_algo_pranavpatel_ca-1.0.3.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
587483a03f455d39a83ce21e35fa03792c48852655d2fafe411fac8dd6cb4e87
BLAKE2b-256 checksum
How to use checksums
ff8a6ffe10db080e54e22ef9f07aac5bdba3896575ff5617095d922ade5a68a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release files / kombin_algo_pranavpatel_ca-1.0.3-py3-none-any.whl

Download URL kombin_algo_pranavpatel_ca-1.0.3-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1dca416ed417cdac180631faaf58748ed076d6d3e7cfea24d92f596a7de42afc
BLAKE2b-256 checksum
How to use checksums
5f51b1e1922870fea33d5ce862607b60b5dcad00f80e8f34bcaec1e25ea567ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page