<jupyter_start><jupyter_text>Day 17The elves bought too much eggnog again - 150 liters this time. To fit it all into your refrigerator, you'll need to move it into smaller containers. You take an inventory of the capacities of the available containers.For example, suppose you have containers of size 20, 15, 10, 5, and 5 liters. If you need to store 25 liters, there are four ways to do it:    15 and 10    20 and 5 (the first 5)    20 and 5 (the second 5)    15, 5, and 5Filling all containers entirely, how many different combinations of containers can exactly fit all 150 liters of eggnog?  Puzzle 1<jupyter_code>from itertools import combinations
from typing import List


def find_combinations(containers:List[int], total:int):
    """Return combinations of containers whose sizes sum to the total
    
    :param containers: list of container sizes
    :param total: total size to be contained
    """
    valid = []
    for count in range(1, len(containers) + 1):
        valid.extend([_ for _ in combinations(containers, count) if sum(_) == total])
    return valid
containers = (20, 15, 10, 5, 5)
total = 25

find_combinations(containers, total)<jupyter_output><empty_output><jupyter_text>Solution<jupyter_code>total = 150

with open("day17.txt", "r") as ifh:
    containers = [int(_.strip()) for _ in ifh.readlines()]

valid = find_combinations(containers, total)
len(valid)<jupyter_output><empty_output><jupyter_text>Puzzle 2While playing with all the containers in the kitchen, another load of eggnog arrives! The shipping and receiving department is requesting as many containers as you can spare.Find the minimum number of containers that can exactly fit all 150 liters of eggnog. How many different ways can you fill that number of containers and still hold exactly 150 litres?In the example above, the minimum number of containers was two. There were three ways to use that many containers, and so the answer there would be 3.<jupyter_code>valid_sizes = [(len(_), _) for _ in valid]
len([_ for _ in valid_sizes if _[0] == 4])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07287644787644787, 'fraction_numerical': 0.029922779922779922, 'mean_word_length': 4.602702702702703, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '512416', 'license': 'MIT', 'n_tokens_mistral': 645, 'n_tokens_neox': 582, 'n_words': 276, 'path': 'day17.ipynb', 'repo_name': 'widdowquinn/aoc2015', 'size': '2072'}