-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution.py
More file actions
35 lines (26 loc) · 939 Bytes
/
solution.py
File metadata and controls
35 lines (26 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def wrapping_paper(dim: str) -> int:
"""
Computes the required wrapping paper for a single box.
"""
l, w, h = map(int, dim.split('x'))
return 2*l*w + 2*l*h + 2*w*h + min(l*w, l*h, w*h)
def ribbon(dim: str) -> int:
"""
Computes the required ribbon length for a single box.
"""
l, w, h = map(int, dim.split('x'))
return l * w * h + min((2*l + 2*w), (2*l + 2*h), (2*w + 2*h))
def solve_part1_slow(input: str) -> int:
pass
def solve_part1_fast(input: str) -> int:
"""
Computes the total requrired amount of wrapping paper for all boxes in the input.
"""
return sum(wrapping_paper(dim) for dim in input.splitlines())
def solve_part2_slow(input: str) -> int:
pass
def solve_part2_fast(input: str) -> int:
"""
Computes the total required length of ribbon for all boxes in the input.
"""
return sum(ribbon(dim) for dim in input.splitlines())