AOC/2023/day02/src/part2.py

18 lines
416 B
Python
Raw Normal View History

2023-12-02 07:06:18 -05:00
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)