aoc-2015/day2/so1.py
2020-11-29 21:32:13 +01:00

29 lines
619 B
Python

base = lambda l,w: l*w
front = lambda w,h: w*h
side = lambda h,l: h*l
def paper(l: int, w: int, h: int):
base = l*w
front = w*h
side = h*l
sup = min(base, front, side)
return 2*base + 2*front + 2*side + sup
def paper_from_str(s: str):
l, w, h = map(int, s.split('x'))
return paper(l, w, h)
def test():
assert paper_from_str("2x3x4") == 58
assert paper_from_str("1x1x10") == 43
def solution():
s = 0
with open("in1") as puzzle:
for l in puzzle:
s += paper_from_str(l)
return s
if __name__ == "__main__":
print(f"Total paper: {solution()}")