Some checks reported errors
continuous-integration/drone/push Build encountered an error
27 lines
No EOL
732 B
Python
27 lines
No EOL
732 B
Python
#!/usr/bin/env python
|
|
# 2025 - Advent Of Code 3 - part 2
|
|
|
|
# file = 'input_example.txt'
|
|
file = 'input.txt'
|
|
|
|
MAX_DIGIT = 12
|
|
|
|
joltage_sum = 0
|
|
with open(file, encoding="utf-8") as f:
|
|
max_num = [0] * MAX_DIGIT
|
|
for line in f.readlines():
|
|
pos_max = 0
|
|
for digit in range(0, MAX_DIGIT):
|
|
max_num[digit] = 0
|
|
for n in range(pos_max, len(line.strip()) - MAX_DIGIT + digit + 1):
|
|
if int(line[n]) > max_num[digit]:
|
|
max_num[digit] = int(line[n])
|
|
pos_max = n
|
|
pos_max += 1
|
|
|
|
joltage = [str(x) for x in max_num]
|
|
print(''.join(joltage))
|
|
|
|
joltage_sum += int(''.join(joltage))
|
|
|
|
print(f'Total Joltage: {joltage_sum}') |