20 lines
357 B
Python
20 lines
357 B
Python
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import re
|
|
|
|
input_file = sys.argv[1]
|
|
|
|
with open(input_file) as fd:
|
|
lines = [line.rstrip() for line in fd.readlines()]
|
|
|
|
t = 0
|
|
reg = r"mul\(([0-9]+),([0-9]+)\)"
|
|
for line in lines:
|
|
for match in re.findall(reg, line):
|
|
ast, bst = match
|
|
a, b = int(ast), int(bst)
|
|
m = a * b
|
|
t += m
|
|
print(t)
|