advent-of-code/src/holt59/aoc/2015/day2.py

16 lines
413 B
Python
Raw Normal View History

2024-01-04 17:27:17 +00:00
import sys
import numpy as np
lines = sys.stdin.read().splitlines()
l, w, h = np.array([[int(c) for c in line.split("x")] for line in lines]).T
lw, wh, hl = (l * w, w * h, h * l)
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(l * w * h + 2 * np.min(np.stack([l + w, l + h, h + w]), axis=0))
print(f"answer 2 is {answer_2}")