Day 2 part 2

This commit is contained in:
IamTheFij 2023-12-02 14:11:25 -08:00
parent d1b8c279de
commit 548a009d30

View File

@ -58,6 +58,25 @@ def part1(input: Path) -> int:
return total
def part2(input: Path) -> int:
total = 0
with input.open() as f:
for line in f:
bag = Grab(red=0, blue=0, green=0)
game = parse_line(line)
power = 1
for color in bag:
bag[color] = max(grab[color] for grab in game.grabs)
power *= bag[color]
# print(bag, power)
total += power
return total
if __name__ == "__main__":
answer1 = part1(Path("./input.txt"))
print("part 1", answer1)
answer2 = part2(Path("./input.txt"))
print("part 2", answer2)