Day 3 - Advent of Code 2025
3 December 2025
Working solutions for the day 3 puzzles.
Part One
""" day_03_01.py """
# usage: python3 day_03_01.py < input
import sys
def max_joltage(battery_bank):
""" largest two digit number """
b = battery_bank.strip()
j = max(b[:-1])
joltage = j + max(b[b.find(j) + 1:])
return int(joltage)
with sys.stdin as infile:
total = sum(max_joltage(bank) for bank in infile)
print(total)Part Two
""" day_03_02.py """
# usage: python3 day_03_02.py < input
import sys
def max_joltage(battery_bank):
""" largest twelve digit number """
b = battery_bank.strip()
output = ''
for target in range(12, 0, -1):
size = len(b)
if size == target:
output += b
break
digit = max(b[:size - target + 1])
i = b.find(digit)
output += digit
b = b[i + 1:]
return int(output)
with sys.stdin as infile:
total = sum(max_joltage(bank) for bank in infile)
print(total)