1
0
Fork 0
adventofcode/2015/2/wrap.py

12 lines
451 B
Python
Executable File

#!/usr/bin/env python3
import sys
data = [tuple(int(w) for w in l.strip().split('x')) for l in sys.stdin.readlines()]
total,ribbon = 0,0
for d in data:
surfaces = (d[0] * d[1], d[1] * d[2], d[0] * d[2])
total = total + 2 * surfaces[0] + 2 * surfaces[1] + 2 * surfaces[2] + min(surfaces)
perimeters = (2 * (d[0] + d[1]), 2 * (d[1] + d[2]), 2 * (d[0] + d[2]))
ribbon = ribbon + min(perimeters) + d[0] * d[1] * d[2]
print(total, ribbon)