Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def much_wrapping_paper(l, w, h):
- r = 2 * l * w + 2 * w * h + 2 * h * l
- return r + min(l * w, w * h, h * l)
- def much_ribbon(l, w, h):
- a, b = sorted((l, w, h))[:2]
- return 2 * a + 2 * b + l * w * h
- if __name__ == '__main__':
- from re import match
- with open('./input') as f:
- lines = f.read().strip().split('\n')
- res = []
- for l in lines:
- gdict = match('(?P<l>\d+)x(?P<w>\d+)x(?P<h>\d+)', l).groupdict()
- l, w, h = map(int, (gdict['l'], gdict['w'], gdict['h']))
- #res.append(much_wrapping_paper(l, w, h))
- res.append(much_ribbon(l, w, h))
- r = sum(res)
- print('*** Answer2={}'.format(r))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement