add: day03: part2

This commit is contained in:
2025-12-03 12:41:53 +01:00
parent bba8b340d0
commit 686db2cd8e

21
2025/day03/part2.py Normal file
View File

@ -0,0 +1,21 @@
text: str
with open("input.txt") as f:
text = f.read()
total: int = 0
for line in text.splitlines():
lst = [int(char) for char in line]
result: str = ""
start_index: int = 0
for i in range(0, 12):
stop_index: int = i - 11 if i != 11 else len(lst)
sublst = lst[start_index:stop_index]
max_value = max(sublst)
result += str(max_value)
start_index = start_index + sublst.index(max_value) + 1
total += int(result)
print(total)