Skip to main content

A custom combination generator

Project description

Custom Combination

Version 0.0.1

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" -pick 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.1.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.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: custom_combination-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 3df5c4ca28b75af318038e115745758f4b8c2988b8298b9670a6e5965e4a3879
MD5 2f828ac5b73a345f5df8ed3b39488082
BLAKE2b-256 1ec0f3397602afde35f13339882896de5204897679c2a7da5667fc4b3062acea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for custom_combination-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8887b8eb04dbfba8643ed63b101aeae3bde384bff7fec8da4e5744ccf983eff
MD5 851650cc9bcce84c23e96f652f1d7ff4
BLAKE2b-256 abe31e917bac0db4d366d4ed840a497a8fe2737bb5be29aa3ac4ce3b654dc819

See more details on using hashes here.

Provenance

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