22 lines
575 B
Python
22 lines
575 B
Python
|
import sys
|
||
|
input = sys.stdin
|
||
|
total = 0
|
||
|
game_num = 0
|
||
|
for line in input:
|
||
|
game, _, data = line.partition(": ")
|
||
|
game_num += 1
|
||
|
takes = data.split(";")
|
||
|
possible = True
|
||
|
for t in takes:
|
||
|
cubes = t.split(",")
|
||
|
cubes = [x.split() for x in t.split(",")]
|
||
|
cubes = {color: int(n) for n, color in cubes}
|
||
|
possible = possible and \
|
||
|
cubes.get('green', 0) <= 13 and \
|
||
|
cubes.get('blue', 0) <= 14 and \
|
||
|
cubes.get("red", 0) <= 12
|
||
|
if possible:
|
||
|
total += game_num
|
||
|
|
||
|
print(total)
|