You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
314 B
13 lines
314 B
1 month ago
|
import re
|
||
|
|
||
|
lines = [l for l in open("input.txt", 'r').read().splitlines()]
|
||
|
|
||
|
summa, x = 0, []
|
||
|
|
||
|
for l in lines:
|
||
|
x = [i.span() for i in re.finditer("mul\([0-9]{1,3},[0-9]{1,3}\)", l)]
|
||
|
for start, end in x:
|
||
|
tup = l[start:end].split(',')
|
||
|
summa += int(tup[0][4:]) * int(tup[1][:-1])
|
||
|
|
||
|
print(summa)
|