def read_from_file(file_name): _file = open(file_name, 'r') _read = _file.read().split('\n') _file.close() return _read boxes = read_from_file('inputs/day02.input') def solve1(): total = 0 for i, box in enumerate(boxes): sbox = box.split("x") l = int(sbox[0]) w = int(sbox[1]) h = int(sbox[2]) total += 2*l*w + 2*l*h + 2*w*h + min([l*w, l*h, w*h]) boxes[i] = (l, w, h) return total def solve2(): total = 0 for box in boxes: l = box[0] w = box[1] h = box[2] total += 2 * min([l + w, w + h, h + l]) + l*w*h return total print("Pt1:", solve1()) print("Pt2:", solve2())