d2
This commit is contained in:
parent
b4c1879c1b
commit
6907bff638
@ -1,4 +1,5 @@
|
|||||||
import re
|
import re
|
||||||
|
import math
|
||||||
|
|
||||||
def get_dimentions(inp: str) -> tuple:
|
def get_dimentions(inp: str) -> tuple:
|
||||||
result = re.match("(\d+)x(\d+)x(\d+)",inp)
|
result = re.match("(\d+)x(\d+)x(\d+)",inp)
|
||||||
@ -7,9 +8,18 @@ def get_dimentions(inp: str) -> tuple:
|
|||||||
def get_wrap(inp: tuple) -> int:
|
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])
|
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:
|
def get_rubon_present(inp: tuple) -> int:
|
||||||
presents = map(get_dimentions, map(str.strip, f.readlines()))
|
sides = list(inp)
|
||||||
wrap_for_each = map(get_wrap, presents)
|
sides.remove(max(inp))
|
||||||
print(sum(wrap_for_each))
|
return (sides[0] + sides[1]) * 2
|
||||||
|
|
||||||
# TODO: Missing part two
|
def get_rubon_bow(inp: tuple) -> int:
|
||||||
|
return math.prod(inp)
|
||||||
|
|
||||||
|
with open("input", "r") as f:
|
||||||
|
presents = list(map(get_dimentions, map(str.strip, f.readlines())))
|
||||||
|
wrap_for_each = list(map(get_wrap, presents))
|
||||||
|
rubon_for_each = list(map(lambda e: get_rubon_present(e) + get_rubon_bow(e), presents))
|
||||||
|
|
||||||
|
print("necessary wrap: " ,sum(wrap_for_each))
|
||||||
|
print("necessary rubbon", sum(rubon_for_each))
|
||||||
|
Loading…
Reference in New Issue
Block a user