34 lines
815 B
Python
Executable File
34 lines
815 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]
|
|
games = line.split(":")[1].split(";")
|
|
valid = True
|
|
for pull in games:
|
|
colors = pull.split(',')
|
|
for color in colors:
|
|
temp = color.split(' ')
|
|
if 'red' in temp[2]:
|
|
if int(temp[1]) > maxred:
|
|
valid = False
|
|
elif 'green' in temp[2]:
|
|
if int(temp[1]) > maxgreen:
|
|
valid = False
|
|
elif 'blue' in temp[2]:
|
|
if int(temp[1]) > maxblue:
|
|
valid = False
|
|
if valid:
|
|
sol += int(gameid)
|
|
|
|
print(sol)
|