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

21 lines
513 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()
2024-01-04 20:05:42 +00:00
length, width, height = np.array(
[[int(c) for c in line.split("x")] for line in lines]
).T
2024-01-04 17:27:17 +00:00
2024-01-04 20:05:42 +00:00
lw, wh, hl = (length * width, width * height, height * length)
2024-01-04 17:27:17 +00:00
answer_1 = np.sum(2 * (lw + wh + hl) + np.min(np.stack([lw, wh, hl]), axis=0))
print(f"answer 1 is {answer_1}")
2024-01-04 20:05:42 +00:00
answer_2 = np.sum(
length * width * height
+ 2 * np.min(np.stack([length + width, length + height, height + width]), axis=0)
)
2024-01-04 17:27:17 +00:00
print(f"answer 2 is {answer_2}")