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

27 lines
510 B
Python

def bow(l,w,h):
base = 2*l + 2*w
front = 2*w + 2*h
side = 2*h + 2*l
rib = min([base, front, side])
rib += l*w*h
return rib
def bow_from_str(s):
l,w,h = map(int, s.split('x'))
return bow(l,w,h)
def test():
assert bow_from_str("2x3x4") == 34
assert bow_from_str("1x1x10") == 14
def solution():
s = 0
with open("in2") as puzzle:
for l in puzzle:
s += bow_from_str(l)
return s
if __name__ == "__main__":
print(f"Bow: {solution()}")