2023 2-1
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user