34 lines
818 B
Python
34 lines
818 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
def numword2int(text):
|
|
text = text.replace("one", "o1e")
|
|
text = text.replace("two", "t2o")
|
|
text = text.replace("three", "t3e")
|
|
text = text.replace("four", "f4r")
|
|
text = text.replace("five", "f5e")
|
|
text = text.replace("six", "s6x")
|
|
text = text.replace("seven", "s7n")
|
|
text = text.replace("eight", "e8t")
|
|
text = text.replace("nine", "n9e")
|
|
# text = text.replace("zero", "0")
|
|
return text
|
|
|
|
|
|
input_file = open("input-org", "r")
|
|
|
|
summe = 0
|
|
for line in input_file:
|
|
v1, v2 = "", ""
|
|
line = numword2int(line.strip())
|
|
for b in line:
|
|
if b.isdigit() and v1 == "":
|
|
v1 = b
|
|
if b.isdigit() and v1 != "":
|
|
v2 = b
|
|
print(v1+v2, line)
|
|
summe += int(v1+v2)
|
|
|
|
input_file.close()
|
|
print(summe)
|