This commit is contained in:
Mark Hoekveen
2024-11-12 14:11:30 +01:00
parent 092cae3143
commit d548196d48
2 changed files with 125 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
most = {
"red": 12,
"green": 13,
"blue": 14
}
def is_valid(line):
picks = line.split(":")[1].strip().split(";")
for pick in picks:
draws = pick.split(", ")
for draw in draws:
[amount, color] = draw.strip().split(" ")
if int(amount) > most[color]:
return False
return True
id = 0
total = 0
with open("input.txt", "r") as f:
for line in f.readlines():
id += 1
if is_valid(line):
print("Possible!")
total += id
print(total)