Advent of code 2015 solutions https://adventofcode.com/2015/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.py 386B

1234567891011121314151617
  1. #!/usr/bin/python
  2. with open('2.txt', 'r') as file:
  3. input = file.read()
  4. paper = 0
  5. ribbon = 0
  6. for line in input.split('\n'):
  7. (w, h, d) = [int(x) for x in line.split('x')]
  8. areas = [w*h, w*d, h*d]
  9. perims = [2 * x for x in [w+h, w+d, h+d]]
  10. paper += sum(areas) * 2 + min(areas)
  11. ribbon += min(perims) + w*h*d
  12. print("Paper: %s" % paper)
  13. print("Ribbon: %s" % ribbon)