Day 10 - Advent of Code 2025
10 December 2025
Working solutions for the day 10 puzzles.
Part One
""" day_10_01.py """
# usage: python3 day_10_01.py
from itertools import product
def get(filename):
""" contents of filename """
with open(filename, 'r', encoding='utf-8') as infile:
data = infile.read()
return data
def test(data, given_solution):
""" testing """
assert solve(data) == given_solution
def push(control, status):
""" push control with given status """
return [value if i not in control else not value
for i, value in enumerate(status)]
def parse_state(text):
""" text to boolean """
return [i == '#' for i in text[1:-1]]
def parse_buttons(text):
""" text to tuple """
def t2t(text):
""" text to tuple """
return tuple(int(i) for i in text[1:-1].split(','))
return [t2t(i) for i in text]
def solve(data):
""" solve the puzzle """
machines = [(parse_state(s), parse_buttons(b))
for s, *b, _ in [row.split() for row in data.splitlines()]]
tally = []
for goal, buttons in machines:
least = float('inf')
for combo in product([0, 1], repeat=len(buttons)):
state = [False for _ in goal]
for i, press in enumerate(combo):
if press == 1:
state = push(buttons[i], state)
if state == goal:
least = min(least, sum(combo))
tally.append(least)
return sum(tally)
if __name__ == '__main__':
test(get('example01'), 7)
puzzle = get('input')
solution = solve(puzzle)
print(solution)
Part Two
