16 lines
504 B
Python
16 lines
504 B
Python
|
import re
|
||
|
|
||
|
def get_dimentions(inp: str) -> tuple:
|
||
|
result = re.match("(\d+)x(\d+)x(\d+)",inp)
|
||
|
return tuple(map(int, result.groups()))
|
||
|
|
||
|
def get_wrap(inp: tuple) -> int:
|
||
|
return 2 * inp[0] * inp[1] + 2 * inp[1] * inp[2] + 2 * inp[2] * inp[0] + min(inp[0] * inp[1], inp[1] * inp[2], inp[2] * inp[0])
|
||
|
|
||
|
with open("input", "r") as f:
|
||
|
presents = map(get_dimentions, map(str.strip, f.readlines()))
|
||
|
wrap_for_each = map(get_wrap, presents)
|
||
|
print(sum(wrap_for_each))
|
||
|
|
||
|
# TODO: Missing part two
|