2025 - Day 3 part 2
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
kleph 2025-12-05 17:01:14 +01:00
parent cbdd34e375
commit 16ba6ca450

27
2025/3/3_2.py Normal file
View file

@ -0,0 +1,27 @@
#!/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}')