advent-of-code/src/holt59/aoc/2015/day2.py
2024-01-04 21:05:42 +01:00

21 lines
513 B
Python

import sys
import numpy as np
lines = sys.stdin.read().splitlines()
length, width, height = np.array(
[[int(c) for c in line.split("x")] for line in lines]
).T
lw, wh, hl = (length * width, width * height, height * length)
answer_1 = np.sum(2 * (lw + wh + hl) + np.min(np.stack([lw, wh, hl]), axis=0))
print(f"answer 1 is {answer_1}")
answer_2 = np.sum(
length * width * height
+ 2 * np.min(np.stack([length + width, length + height, height + width]), axis=0)
)
print(f"answer 2 is {answer_2}")