25 lines
733 B
Python
25 lines
733 B
Python
maxs = {"red": 12, "green": 13, "blue": 14}
|
|
|
|
gid = 0
|
|
power_sum = 0
|
|
|
|
with open("input") as lines:
|
|
for line in lines.readlines():
|
|
gid += 1
|
|
line = line.rstrip()
|
|
game_full, sets = line.split(":")
|
|
game, gid_str = game_full.split(" ")
|
|
assert int(gid_str) == gid
|
|
possible = True
|
|
gcs = {"red": 0, "green": 0, "blue": 0}
|
|
for seet in sets.split(";"):
|
|
for color in seet.split(","):
|
|
amount_str, color = color.strip().split(" ")
|
|
amount = int(amount_str)
|
|
gcs[color] = max(amount, gcs[color])
|
|
power = gcs["red"] * gcs["green"] * gcs["blue"]
|
|
print(gid, power)
|
|
power_sum += power
|
|
|
|
print(power_sum)
|