Day 1 - Advent of Code 2025
1 December 2025
Working solutions for the day 1 puzzles.
Part One
""" day_01_01.py """
# usage: python3 day_01_01.py
def get(filename):
""" contents of filename """
with open(filename, 'r', encoding='utf-8') as infile:
data = infile.read().strip()
return data
def test(data, given_solution):
""" testing """
assert solve(data) == given_solution
def solve(data):
""" solve the puzzle """
zero_count = 0
dial = 50
for rotation in data.split():
clicks = int(rotation[1:])
if rotation[0].lower() == 'l':
clicks = -clicks
dial = (dial + clicks) % 100
if dial == 0:
zero_count += 1
return zero_count
if __name__ == '__main__':
test(get('example01'), 3)
puzzle = get('input')
solution = solve(puzzle)
print(solution)
Part Two
""" day_01_02.py """
# usage: python3 day_01_02.py
def get(filename):
""" contents of filename """
with open(filename, 'r', encoding='utf-8') as infile:
data = infile.read().strip()
return data
def test(data, given_solution):
""" testing """
assert solve(data) == given_solution
def turn(pos, move, tally):
""" rotate from pos counting passes of zero """
count, clicks = divmod(int(move[1:]), 100)
dx = -1 if move[0].lower() == 'l' else 1
x = pos
for _ in range(clicks):
x = (x + dx) % 100
if x == 0:
count += 1
return x, tally + count
def solve(data):
""" solve the puzzle """
zero_count = 0
dial = 50
for rotation in data.split():
dial, zero_count = turn(dial, rotation, zero_count)
return zero_count
if __name__ == '__main__':
test(get('example01'), 6)
puzzle = get('input')
solution = solve(puzzle)
print(solution)
