#!/bin/python3 import sys,re from pprint import pprint sys.path.insert(0, '../../') from fred import list2int input_f = 'input' part = 2 ######################################### # # # Part 1 # # # ######################################### result = 0 if part == 1: with open(input_f) as file: for line in file: tmp = line.rstrip().split('x') tmp = list(map(int,tmp)) first = tmp[0] * tmp[1] second = tmp[1] * tmp[2] third = tmp[2] * tmp[0] smallest = min(first,second,third) result = result + (2*first) + (2*second) + (2*third) + smallest print(result) ######################################### # # # Part 2 # # # ######################################### result = 0 if part == 2: with open(input_f) as file: for line in file: tmp = line.rstrip().split('x') tmp = list(map(int,tmp)) first = tmp[0] * tmp[1] second = tmp[1] * tmp[2] third = tmp[2] * tmp[0] #2*l*w + 2*w*h + 2*h*l smallest = min(first,second,third) tmp.sort() rib = tmp[0]+tmp[0]+tmp[1]+tmp[1] bow = tmp[0]*tmp[1]*tmp[2] result = result + rib + bow print(result)