#!/usr/bin/python def solve_part1(boxes): result = 0 for b in boxes: faces = [b[0]* b[1], b[1] * b[2], b[2] * b[0]] result += 2 * sum(faces) + min(faces) return result def solve_part2(boxes): result = 0 for b in boxes: perims = [2 * (b[0] + b[1]), 2 * (b[1] + b[2]), 2 * (b[2] + b[0])] volume = b[0] * b[1] * b[2] result += min(perims) + volume return result def main(): # Read box dimensions from input text file with open("input.txt", "r") as f: lines = f.read().splitlines() # Parse the dimensions into tuples (x, y, z) boxes = [] for line in lines: dims = line.split("x") b = tuple([int(d) for d in dims]) boxes.append(b) print("Part 1 solution:", solve_part1(boxes)) # 1586300 for me print("Part 2 solution:", solve_part2(boxes)) # 3737498 for me if __name__ == "__main__": main()