Metadata-Version: 2.4
Name: custom-combination
Version: 0.0.2
Summary: A custom combination generator
Project-URL: Homepage, https://github.com/yilmazhasan/custom_combination
Project-URL: Issues, https://github.com/yilmazhasan/custom_combination/issues
Author-email: Hasan YILMAZ <ylmzhsn@proton.me>, Reego Software <reego.software@gmail.com>
License-File: LICENCE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Requires-Dist: typer
Description-Content-Type: text/markdown

# Custom Combination

> Version 0.0.2

Python implementation for Custom Combination.

## Usage

### Programmatic usage

```py
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

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

Output:

```sh
['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

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

or shortly:

```sh
--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:

```sh
[
    ["b", "c", "c"],
    ["b", "c", "d"]
]
```
