Files
AOC_2024/03a.py
2024-12-10 14:36:10 -06:00

16 lines
264 B
Python
Executable File

#!/usr/bin/python
import re
with open('03a.txt') as f:
text = f.read()
reg = re.compile(r'mul\((?P<num1>[0-9]+),(?P<num2>[0-9]+)\)')
total = 0
for match in reg.finditer(text):
total += int(match.group('num1')) * int(match.group('num2'))
print(total)