from typing import Any, Iterator import numpy as np from ..base import BaseSolver class Solver(BaseSolver): def solve(self, input: str) -> Iterator[Any]: length, width, height = np.array( [[int(c) for c in line.split("x")] for line in input.splitlines()] ).T lw, wh, hl = (length * width, width * height, height * length) yield np.sum(2 * (lw + wh + hl) + np.min(np.stack([lw, wh, hl]), axis=0)) yield np.sum( length * width * height + 2 * np.min( np.stack([length + width, length + height, height + width]), axis=0 ) )