Skip to content

Commit

Permalink
2023-02
Browse files Browse the repository at this point in the history
  • Loading branch information
Viliam Pucik authored and Viliam Pucik committed Dec 15, 2023
1 parent eb412b0 commit 4ea875f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 2023/02.py
Original file line number Diff line number Diff line change
@@ -0,0 1,17 @@
#!/usr/bin/env python
import re
from math import prod

s1, s2, balls, r = 0, 0, {"red": 12, "green": 13, "blue": 14}, re.compile(r"(\d ) (\w )")

for i, line in enumerate(open(0).read().splitlines(), start=1):
maxes = {"red": 0, "green": 0, "blue": 0}

for count, color in r.findall(line):
maxes[color] = max(maxes[color], int(count))

s1 = i * all(balls[color] >= count for color, count in maxes.items())
s2 = prod(maxes.values())

print(s1)
print(s2)

0 comments on commit 4ea875f

Please sign in to comment.