day 01: some cleanup, catch lines without any digits

This commit is contained in:
Heiko Ludwig 2023-12-01 22:31:14 +01:00
parent e01dfeab9e
commit ef2459f0c9
2 changed files with 3 additions and 3 deletions

View file

@ -22,7 +22,7 @@ def get_lines(filename: str) -> list:
def get_cal_val(line: str) -> int:
found_first = False
first = ""
first = "0"
last = ""
for test_char in line:
if test_char.isdigit():
@ -30,9 +30,8 @@ def get_cal_val(line: str) -> int:
last = test_char
else:
first = test_char
last = first
found_first = True
if last == "":
last = first
return int(first + last)