32 lines
711 B
Python
Executable File
32 lines
711 B
Python
Executable File
#!/usr/bin/python
|
|
|
|
inputfile = open("input.txt", "r")
|
|
lines = inputfile.readlines()
|
|
|
|
maxred = 12
|
|
maxgreen = 13
|
|
maxblue = 14
|
|
|
|
sol = 0
|
|
|
|
for line in lines:
|
|
line = line.replace('\n', "")
|
|
gameid = line.split(":")[0].split(" ")[1]
|
|
game = line.split(":")[1].split(",")
|
|
valid = True
|
|
for color in game:
|
|
temp = color.split(' ')
|
|
if 'red' in temp[1]:
|
|
if int(temp[0]) > maxred:
|
|
valid = False
|
|
elif 'green' in temp[1]:
|
|
if int(temp[0]) > maxgreen:
|
|
valid = False
|
|
elif 'blue' in temp[1]:
|
|
if int(temp[0]) > maxblue:
|
|
valid = False
|
|
if not valid:
|
|
sol += gameid
|
|
|
|
print(sol)
|