15 lines
291 B
Python
15 lines
291 B
Python
with open('puzzle.txt', 'r') as f:
|
|
lines = f.read().splitlines()
|
|
|
|
import re
|
|
|
|
total_mul = 0
|
|
|
|
for line in lines:
|
|
match = re.findall(r"mul\([0-9]+,[0-9]+\)", line)
|
|
for mul in match:
|
|
x, y = map(int, mul.strip('mul()').split(','))
|
|
|
|
total_mul += x * y
|
|
|
|
print(total_mul) |