aoc23/02/part1.py

8 lines
340 B
Python
Raw Normal View History

2023-12-03 03:12:13 -06:00
import re, sys
print(sum(
int(re.search("[0-9]+", line).group())
for line in sys.stdin.readlines()
if all(int(r) <= 12 for r in re.findall(r"[0-9]+(?= red)", line))
and all(int(g) <= 13 for g in re.findall(r"[0-9]+(?= green)", line))
and all(int(b) <= 14 for b in re.findall(r"[0-9]+(?= blue)", line))))