From a6a126cc3da523d04135df13223b7d7cc81d608e Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 21 May 2025 22:26:24 +0100 Subject: [PATCH] 2015: d17: ex1: add solution --- 2015/d17/ex1/ex1.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 2015/d17/ex1/ex1.py diff --git a/2015/d17/ex1/ex1.py b/2015/d17/ex1/ex1.py new file mode 100755 index 0000000..8cbeb5b --- /dev/null +++ b/2015/d17/ex1/ex1.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import itertools +import sys + +TOTAL_EGGNOG = 150 + + +def solve(input: str) -> int: + def parse(input: str) -> list[int]: + return [int(line) for line in input.splitlines()] + + containers = parse(input) + return sum( + sum(combination) == TOTAL_EGGNOG + for combination in itertools.chain.from_iterable( + itertools.combinations(containers, i) for i in range(1, len(containers) + 1) + ) + ) + + +def main() -> None: + input = sys.stdin.read() + print(solve(input)) + + +if __name__ == "__main__": + main()