# Day 17: No such thing as too much


```python
containers = [50, 44, 11, 49, 42, 46, 18, 32, 26, 40, 21, 7, 18, 43, 10, 47, 36, 24, 22, 40]
```

## Day 17.1


```python
from sympy.abc import x
from sympy import Poly
```


```python
def combine(total, containers):
    poly = 1
    for i in containers:
        poly *= (1 + x**i)
    poly = Poly(poly)
    return poly.all_coeffs()[total]
```


```python
combine(150, containers)
```




    654



## Day 17.2


```python
from sympy.abc import x, y
```


```python
def min_combine(total, containers):
    poly = 1
    for i in containers:
        poly *= (y + x**i)
    poly = Poly(poly)
    coeff_dict = dict(zip(poly.monoms(), poly.coeffs()))
    master_monom = sorted([m for m in poly.monoms() if m[0] == total], key=lambda a: a[1], reverse=True)[0]
    return coeff_dict[master_monom]
```


```python
min_combine(150, containers)
```




    57



c12472e297470db03fce5768c7e5c6577c403707
ipynb
Jupyter Notebook
2015/ferran/day17.ipynb
bbglab/adventofcode
65b6d8331d10f229b59232882d60024b08d69294
MIT
2015/ferran/day17.ipynb
bbglab/adventofcode
65b6d8331d10f229b59232882d60024b08d69294
MIT
2015/ferran/day17.ipynb
bbglab/adventofcode
65b6d8331d10f229b59232882d60024b08d69294
MIT
2016-12-02T09:20:42.000Z
2021-12-01T13:31:07.000Z
Qwen/Qwen-72B
1. YES
2. YES