add: day03: part2
This commit is contained in:
21
2025/day03/part2.py
Normal file
21
2025/day03/part2.py
Normal 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)
|
||||
Reference in New Issue
Block a user