advent_of_code

advent of code solves
git clone https://git.pastanoggin.com/advent_of_code.git
Log | Files | Refs

nomath.py (497B)


      1 def recprism_area(l, w, h):
      2     return 2*l*w + 2*w*h + 2*h*l
      3 
      4 def smallest_side(l, w, h):
      5     return min(l*w, w*h, h*l)
      6 
      7 def ribbon_wrap(l, w, h):
      8     di = [l, w, h]
      9     stmin = min(di)
     10     di.remove(stmin)
     11     ndmin = min(di)
     12     return 2*stmin + 2*ndmin
     13 
     14 def ribbon_bow(l, w, h):
     15     return l*w*h
     16 
     17 order = 0
     18 with open("input") as f:
     19     for line in [l.strip() for l in f.readlines()]:
     20         di = list(map(int, line.split("x")))
     21         order += ribbon_wrap(*di) + ribbon_bow(*di)
     22 print(order)