remove python folder

This commit is contained in:
2023-12-01 13:31:20 +01:00
parent a56270c0db
commit b0326283f2
3 changed files with 0 additions and 0 deletions

12
2023/day01/src/part1.py Normal file
View File

@ -0,0 +1,12 @@
text: str = open("input.txt", "r").read()
value: int = 0
for line in text.split("\n"):
for index, chars in enumerate([line[::-1], line]):
for char in chars:
if (char.isdigit()):
value += int(char) * 10 ** index
break;
print(value)

22
2023/day01/src/part2.py Normal file
View File

@ -0,0 +1,22 @@
text: str = open("input.txt", "r").read()
value: int = 0
digits = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
def get_index(text:str):
if (text[0].isdigit()):
return (int(text[0]))
for i, value, in enumerate(digits):
if (text.startswith(value)):
return i;
for line in text.split("\n"):
for i, chars in enumerate([line[::-1], line]):
for j in range(len(chars)):
digit: int = get_index(chars[j::(1, -1)[i == 0]])
if digit is not None:
value += digit * 10 ** i
break;
print(value)