parent
0a5c75059a
commit
42f4e5cd64
1 changed files with 16 additions and 0 deletions
@ -0,0 +1,16 @@ |
|||||||
|
lines = [i for i in open("input.txt", 'r').read().splitlines()] |
||||||
|
|
||||||
|
sum = 0 |
||||||
|
|
||||||
|
for l in lines: |
||||||
|
sets = [[j.split(" ") for j in i.split(', ')] for i in l.split(": ")[1].split('; ')] |
||||||
|
valid = True |
||||||
|
for set in sets: |
||||||
|
for cubes in set: |
||||||
|
cubes[0] = int(cubes[0]) |
||||||
|
if (cubes[1] == "red" and cubes[0] > 12) or (cubes[1] == "green" and cubes[0] > 13) or (cubes[1] == "blue" and cubes[0] > 14): |
||||||
|
valid = False |
||||||
|
if valid: |
||||||
|
sum += int(l.split(": ")[0].split(" ")[1]) |
||||||
|
|
||||||
|
print(sum) |
Loading…
Reference in new issue