#!/usr/bin/env python total = 0 with open("inputd2.txt", "r") as f: for line in f: dimensions = [int(x) for x in line.split("x")] l = dimensions[0] w = dimensions[1] h = dimensions[2] lw = l * w wh = w * h hl = h * l smallest = wh if (lw < hl and lw < wh): smallest = lw elif (hl < wh): smallest = hl total += (2 * lw) + (2 * hl) + (2 * wh) + smallest print(total)