mirror of
https://github.com/Xevion/advent-of-code.git
synced 2025-12-05 23:14:16 -06:00
2015 day 2part 1 & 2
This commit is contained in:
1000
2015/day-2/input
Normal file
1000
2015/day-2/input
Normal file
File diff suppressed because it is too large
Load Diff
22
2015/day-2/python/main.py
Normal file
22
2015/day-2/python/main.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
PATH = os.path.join(sys.path[0], '..', 'input')
|
||||
DATA = open(PATH).readlines()
|
||||
|
||||
paper = 0
|
||||
ribbon = 0
|
||||
|
||||
for line in DATA:
|
||||
l, w, h = list(map(int, line.split('x')))
|
||||
|
||||
areas = [l*w, w*h, h*l]
|
||||
volume = l*w*h
|
||||
perimeters = [2*(l+w), 2*(h+w), 2*(h+l)]
|
||||
areas.extend(areas)
|
||||
|
||||
paper += sum(areas) + min(areas)
|
||||
ribbon += min(perimeters) + volume
|
||||
|
||||
print(paper)
|
||||
print(ribbon)
|
||||
Reference in New Issue
Block a user