first fix

This commit is contained in:
2023-12-07 20:56:11 +01:00
parent fec2fb31b6
commit 06cec4dbc0

View File

@@ -12,20 +12,23 @@ sol = 0
for line in lines:
line = line.replace('\n', "")
gameid = line.split(":")[0].split(" ")[1]
game = line.split(":")[1].split(",")
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
for pull in game:
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 not valid:
sol += gameid
print(gameid)
sol += int(gameid)
print(sol)