Created
December 3, 2015 22:49
-
-
Save RGamberini/1a00547f39b114cda7e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import mul | |
def sqftBox(l,w,h): | |
return 2*l*w + 2*w*h + 2*h*l | |
def areaSmallestSide(l, w, h): | |
return min([l * w, l * h, w * h]) | |
def perimeterSmallestSide(l, w, h): | |
return min([2*l + 2*w, 2*l + 2*h, 2*w + 2*h]) | |
with open("input.txt") as _input: | |
wrappingPaper = 0 | |
ribbon = 0 | |
for line in _input: | |
dimensions = map(int, line.split("x")) | |
wrappingPaper += sqftBox(*dimensions) + areaSmallestSide(*dimensions) | |
ribbon += perimeterSmallestSide(*dimensions) + reduce(mul, dimensions) | |
print("Square feet of wrapping paper: " + str(wrappingPaper)) | |
print("Feet of ribbon: " + str(ribbon)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment