part 1 day 02
This commit is contained in:
20
2023/day02/src/part1.py
Normal file
20
2023/day02/src/part1.py
Normal file
@ -0,0 +1,20 @@
|
||||
text: str = open("input.txt", "r").read()
|
||||
|
||||
bozo_dict: dict = {
|
||||
"red": 12,
|
||||
"green": 13,
|
||||
"blue": 14,
|
||||
}
|
||||
|
||||
value: int = 0
|
||||
|
||||
for line in text.split("\n"):
|
||||
ok = 0
|
||||
game = line.split(": ")
|
||||
for bozo_set in game[1].split("; "):
|
||||
for cube in bozo_set.split(", "):
|
||||
values = cube.split(" ")
|
||||
ok += int(values[0]) > bozo_dict.get(values[1])
|
||||
value = value + int(game[0][5:]) * (ok == 0)
|
||||
|
||||
print(value)
|
Reference in New Issue
Block a user