All checks were successful
continuous-integration/drone/push Build is passing
Co-authored-by: Mikael CAPELLE <mikael.capelle@thalesaleniaspace.com> Co-authored-by: Mikaël Capelle <capelle.mikael@gmail.com> Reviewed-on: #3
25 lines
655 B
Python
25 lines
655 B
Python
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
|
|
)
|
|
)
|