AOC/2023/day02/src/part2.py
2023-12-02 13:06:18 +01:00

18 lines
416 B
Python

text: str = open("input.txt", "r").read()
import math
value: int = 0
for line in text.split("\n"):
ok = 0
game = line.split(": ")
bozo_dict: dict = {}
for bozo_set in game[1].split("; "):
for cube in bozo_set.split(", "):
values = cube.split(" ")
if (bozo_dict.get(values[1], 0) < int(values[0])):
bozo_dict.update({values[1]: int(values[0])})
value += math.prod(bozo_dict.values())
print(value)