Day 6 - Advent of Code 2025
6 December 2025
Working solutions for the day 6 puzzles.
Part One
""" day_06_01.py """
# usage: python3 day_06_01.py < input
import math
import sys
def transpose(matrix):
""" transpose matrix """
rows, cols = len(matrix), len(matrix[0])
return [[matrix[r][c] for r in range(rows)] for c in range(cols)]
with sys.stdin as infile:
hwk = [line.split() for line in infile]
hwk = transpose(hwk)
check = 0
for problem in hwk:
args = map(int, problem[:-1])
if problem[-1] == '+':
answer = sum(args)
else:
answer = math.prod(args)
check += answer
print(check)Part Two
""" day_06_02.py """
# usage: python3 day_06_02.py < input
import sys
def transpose(matrix):
""" transpose matrix """
rows, cols = len(matrix), len(matrix[0])
return [''.join([matrix[r][c] for r in range(rows)])
for c in range(cols)]
with sys.stdin as infile:
hwk = [line.rstrip('\n') for line in infile]
hwk = transpose(hwk) + [' ']
init = {'+': 0, '*': 1}
func = {'+': lambda x, y: x + y, '*': lambda x, y: x * y}
check = 0
answer = None
for num in hwk:
if num[-1] in '+*':
ops = num[-1]
answer = init[ops]
if (n := num[:-1].strip()) == '':
check += answer
continue
answer = func[ops](answer, int(n))
print(check)