diff --git a/01/01.py b/01/01.py index e69de29..6a78ba9 100644 --- a/01/01.py +++ b/01/01.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +def numword2int(text): + text = text.replace("one", "1") + text = text.replace("two", "2") + text = text.replace("three", "3") + text = text.replace("four", "4") + text = text.replace("five", "5") + text = text.replace("six", "6") + text = text.replace("seven", "7") + text = text.replace("eight", "8") + text = text.replace("nine", "9") + # text = text.replace("zero", "0") + return text + + +input_file = open("input", "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)