Example #1
0
    def solve():
        boxes = [[int(d) for d in box.split('x')] for box in day_two.split('\n')]  # hnngh list comprehensions
        ribbon = 0
        for box in boxes:
            box.sort()
            ribbon += 2 * sum(box[:2]) + box[0] * box[1] * box[2]

        return ribbon
Example #2
0
    def solve_one():
        boxes = [[int(d) for d in box.split('x')] for box in day_two.split('\n')]

        areas = 0
        for box in boxes:
            l, w, h = box
            area = (2 * l * w) + (2 * w * h) + (2 * h * l)
            box.sort()
            areas += area + box[0] * box[1]

        return areas
Example #3
0
    def solve():
        boxes = day_two.split('\n')

        areas = []
        for box in boxes:
            l, w, h = dims = [int(x) for x in box.split('x')]
            area = (2 * l * w) + (2 * w * h) + (2 * h * l)
            dims.sort()
            areas.append(area + dims[0] * dims[1])

        return sum(areas)