Skip to main content

A custom combination generator

Project description

Custom Combination

Version 0.0.2

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), ("a", 0)],
    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/app.py --items a,b,c,d -pick a,0 -minp b,1 -max 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.2.tar.gz (4.8 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.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: custom_combination-0.0.2.tar.gz
  • Upload date:
  • Size: 4.8 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.2.tar.gz
Algorithm Hash digest
SHA256 5abd4f6f753e38ecf8a014f30c76b9e17244ba71d612e9b92beaa0b7ed3ed07e
MD5 4fe5ac371ba4e3a7c64fbbf21289686b
BLAKE2b-256 9aeeeaaf5d140cb4c8ffc00fd66ff1f4d38e4e13aa5ccb0c29e68ae969ae4bee

See more details on using hashes here.

Provenance

The following attestation bundles were made for custom_combination-0.0.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for custom_combination-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32953cdd24570d511079f3480a892c8a7d82a16206f7ea0e047b978a0a24bb1a
MD5 f30820499945370d11246fa13da4975b
BLAKE2b-256 233e7bc1992434c07604939c0b35c7fa06359b9b990141fbff0be9a91e33c55d

See more details on using hashes here.

Provenance

The following attestation bundles were made for custom_combination-0.0.2-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