aoc23/02/part2.py

5 lines
215 B
Python

import math, re, sys
print(sum(math.prod(max(int(n) for n in re.findall(f"[0-9]+(?= {color})", line))
for color in ("red", "green", "blue"))
for line in open("input.txt", "rt").readlines()))