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: for line in lines:
line = line.replace('\n', "") line = line.replace('\n', "")
gameid = line.split(":")[0].split(" ")[1] gameid = line.split(":")[0].split(" ")[1]
game = line.split(":")[1].split(",") game = line.split(":")[1].split(";")
valid = True valid = True
for color in game: for pull in game:
temp = color.split(' ') colors = pull.split(',')
if 'red' in temp[1]: for color in colors:
if int(temp[0]) > maxred: temp = color.split(' ')
valid = False if 'red' in temp[2]:
elif 'green' in temp[1]: if int(temp[1]) > maxred:
if int(temp[0]) > maxgreen: valid = False
valid = False elif 'green' in temp[2]:
elif 'blue' in temp[1]: if int(temp[1]) > maxgreen:
if int(temp[0]) > maxblue: valid = False
valid = False elif 'blue' in temp[2]:
if int(temp[1]) > maxblue:
valid = False
if not valid: if not valid:
sol += gameid print(gameid)
sol += int(gameid)
print(sol) print(sol)