38 lines
598 B
Python
38 lines
598 B
Python
![]() |
#!/usr/bin/env python
|
||
|
|
||
|
|
||
|
from sys import stdin
|
||
|
import re
|
||
|
|
||
|
nums = {
|
||
|
'one': '1',
|
||
|
'two': '2',
|
||
|
'three': '3',
|
||
|
'four': '4',
|
||
|
'five': '5',
|
||
|
'six': '6',
|
||
|
'seven': '7',
|
||
|
'eight': '8',
|
||
|
'nine': '9'
|
||
|
}
|
||
|
|
||
|
def read_line():
|
||
|
for line in stdin:
|
||
|
yield line.strip()
|
||
|
|
||
|
def check_number_start(line):
|
||
|
for k,v in nums.items():
|
||
|
if line.startswith(k):
|
||
|
return v
|
||
|
return None
|
||
|
|
||
|
sum = 0
|
||
|
for line in read_line():
|
||
|
for i in range(len(line)):
|
||
|
f = check_number_start(line[i:])
|
||
|
if f is not None:
|
||
|
line = line[:i] + f + line[i + 1:]
|
||
|
digits = re.sub("[^\d]", "", line)
|
||
|
sum += int(digits[0] + digits[-1])
|
||
|
|
||
|
print(sum)
|