18 lines
383 B
Python
18 lines
383 B
Python
""" day3 """
|
|
|
|
import re
|
|
import fileinput
|
|
|
|
def match_all(pending):
|
|
match = re.search(r'mul\(([0-9]{1,3}),([0-9]{1,3})\)',pending)
|
|
if match:
|
|
val = int(match[1])*int(match[2])
|
|
print(f'span={match.span()}')
|
|
return val + match_all(pending[match.span()[1]:])
|
|
return 0
|
|
|
|
input = ''
|
|
for line in fileinput.input():
|
|
input += line
|
|
print(match_all(input))
|