advent/2015/2/sol.py

39 lines
747 B
Python

lines = [i.rstrip() for i in open("input").readlines()]
class Box:
def __init__(self, string):
inter = string.split("x")
self.a = int(inter[0])
self.b = int(inter[1])
self.c = int(inter[2])
def surfacearea(self):
a_0 = self.a * self.b
a_1 = self.b * self.c
a_2 = self.c * self.a
slack = min(a_0, a_1, a_2)
print(slack)
return 2 * a_0 + 2 * a_1 + 2 * a_2 + slack
def bow(self):
arr = [self.a, self.b, self.c]
arr.sort()
tot = 0
tot += 2*arr[0] + 2*arr[1]
tot += self.a * self.b * self.c
return tot
boxes = []
for i in lines:
boxes.append(Box(i))
s = 0
for i in boxes:
s += i.bow()
print(s)