add: day03: part1
This commit is contained in:
17
2025/day03/part1.py
Normal file
17
2025/day03/part1.py
Normal file
@ -0,0 +1,17 @@
|
||||
import math
|
||||
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]
|
||||
first_max_value = max(lst[:-1])
|
||||
first_max_index = lst.index(first_max_value)
|
||||
second_max_value = max(lst[first_max_index + 1:])
|
||||
total += first_max_value * 10 + second_max_value
|
||||
|
||||
|
||||
print(total)
|
||||
Reference in New Issue
Block a user