31 lines
854 B
Python
31 lines
854 B
Python
|
filename = "input.txt"
|
||
|
|
||
|
#red / green / blue
|
||
|
bag = [12, 13, 14]
|
||
|
|
||
|
result = 0
|
||
|
|
||
|
with open(filename, 'r') as f:
|
||
|
for line in f.readlines():
|
||
|
game = line.split(": ")
|
||
|
p = game[1].replace("\n","").split("; ")
|
||
|
i = int(game[0].split(" ")[1])
|
||
|
#print(p)
|
||
|
max = [0, 0, 0]
|
||
|
# par pack
|
||
|
for c in p:
|
||
|
#print(c)
|
||
|
# par jeton
|
||
|
for j in c.split(", "):
|
||
|
k = j.split(" ")
|
||
|
#print(j)
|
||
|
if k[1] == 'red' and max[0] < int(k[0]):
|
||
|
max[0] = int(k[0])
|
||
|
elif k[1] == 'green' and max[1] < int(k[0]):
|
||
|
max[1] = int(k[0])
|
||
|
elif k[1] == 'blue' and max[2] < int(k[0]):
|
||
|
max[2] = int(k[0])
|
||
|
somme = max[0] * max[1] * max[2]
|
||
|
result += somme
|
||
|
|
||
|
print(result)
|