adventofcode/2015/d2/main.py

16 lines
504 B
Python
Raw Normal View History

2023-06-16 19:21:56 +02:00
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