Skip to main content

A custom combination generator

Project description

Custom Combination

Version 0.0.3

Python implementation for Custom Combination.

Usage

Programmatic usage

from custom_combination import CustomCombination

CustomCombination.generate(
    items=[("a", 1), ("b", 2), ("c", 3), "d"],
    pick=3,
    min_picks=[("b", 1)],
    max_picks=[("a", 0)])

CLI usage

custom_combination --items "a,b,b,c,c,c,d" -p 3 -minp "b,1" -maxp "a,0"

Output:

['b', 'c', 'd']
['b', 'c', 'c']

Set up locally for development

  1. Clone the repository

    git clone git@github.com:yilmazhasan/custom_combination.git

  2. Create and activate the virtural environment

    python -m venv .venv

    source .venv/bin/activate

  3. Install requirements:

    pip install -r requirements.txt

  4. Run the app:

    python src/custom_combination/cli.py --items a,b,b,c,c,c,d -p 3 -minp b,1 -maxp a,0

  5. Test the app:

    pytest

Args Explained

--items "a,b,b,c,c,c,d" --pick 3 --min-picks b,1 --max-picks a,0

or shortly:

--items "a,b,b,c,c,c,d" -p 3 -minp b,1 -maxp a,0

This indicates that:

  • We have four items in the set ["a", "b", "c", "d"] but with different frequencies.

  • Thus we have the list as ["a", "b", "b", "c", "c", "c", "d"]

  • We want to generate combinations that have 3 items, which -pick 3 specifies.

  • We want to pick at least:

    • 1 occurrences of "b"
  • We want to pick at max:

    • 0 occurrences of "a"

This indicates the list to generate from is:

["b", "b", "c", "c", "c", "d"] out of

["a", "b", "b", "c", "c", "c", "d"] as "a" is excluded.

Since "b" is to be included once, we need to select 2 more items from the list ["c", "c", "c", "d"], so we can select ["c", "c"] or ["c", "d"]

Expected output:

[
    ["b", "c", "c"],
    ["b", "c", "d"]
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

custom_combination-0.0.3.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

custom_combination-0.0.3-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file custom_combination-0.0.3.tar.gz.

File metadata

  • Download URL: custom_combination-0.0.3.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for custom_combination-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3b5779d87385695c30cf71a0da5ac87af6653019e9f46a855ff837d52efbe0de
MD5 ac95779b6fb9242bb1b4af2b2a479a38
BLAKE2b-256 fb329901f9278285416bff7aaa2fa8180d0f5f0c9b2ebd334b4619cf2821aa3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for custom_combination-0.0.3.tar.gz:

Publisher: publish-to-pypi.yaml on yilmazhasan/custom_combination

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file custom_combination-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for custom_combination-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 643c0f13e67124467130f094668d7fa5e66e2511519916f6266183b1705df909
MD5 5866557b3f1c96beb23d4a59b60309d4
BLAKE2b-256 23fbe84fc0f955d3ddbf1de50321a4397dcd4d178d7127bd4ea0f42ce18f6d46

See more details on using hashes here.

Provenance

The following attestation bundles were made for custom_combination-0.0.3-py3-none-any.whl:

Publisher: publish-to-pypi.yaml on yilmazhasan/custom_combination

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page