mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Add solution day 2.
This commit is contained in:
1000
day2-input.txt
Normal file
1000
day2-input.txt
Normal file
File diff suppressed because it is too large
Load Diff
19
day2.py
Normal file
19
day2.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import fileinput
|
||||||
|
from operator import mul
|
||||||
|
|
||||||
|
totalArea = 0
|
||||||
|
totalRibbon = 0
|
||||||
|
for line in fileinput.input():
|
||||||
|
parts = [int(i) for i in line.split('x')]
|
||||||
|
parts.sort()
|
||||||
|
|
||||||
|
sides = [parts[0] * parts[1], parts[0] * parts[2], parts[1] * parts[2]]
|
||||||
|
totalArea += 2 * sum(sides)
|
||||||
|
|
||||||
|
totalArea += min(sides)
|
||||||
|
totalRibbon += 2 * (parts[0] + parts[1])
|
||||||
|
totalRibbon += reduce(mul, parts, 1)
|
||||||
|
|
||||||
|
print totalArea, "paper"
|
||||||
|
print totalRibbon, "ribbon"
|
||||||
|
|
||||||
Reference in New Issue
Block a user