blob: 9897daea206663acfcc751890a060242f4244e32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/bin/python3
import sys
import re
MAP = {
"one": "1",
"two": "2",
"three": "3",
"four": "4",
"five": "5",
"six": "6",
"seven": "7",
"eight": "8",
"nine": "9",
}
sum = 0
for line in sys.stdin:
line = line.strip()
real_line = ""
for c in range(len(line)):
match = re.search("one|two|three|four|five|six|seven|eight|nine|[0-9]", line[c:])
if match is None:
continue
if match.start() != 0:
continue
found = match.group(0)
if not found in MAP:
real_line += found
else:
real_line += MAP[found]
print(real_line)
num = int(real_line[0]) * 10 + int(real_line[-1])
sum += num
print(f">> {sum}")
|