From a9caf0f5776918712d57fe3176b213a3f5fa3870 Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Mon, 4 Dec 2023 17:13:33 +0100 Subject: [PATCH] Finished 2015-12-02 part 2 --- 2015/day2/part1.py | 2 +- 2015/day2/part2.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 2015/day2/part2.py diff --git a/2015/day2/part1.py b/2015/day2/part1.py index f58fd59..c5faa2a 100644 --- a/2015/day2/part1.py +++ b/2015/day2/part1.py @@ -15,7 +15,7 @@ with open(input_f) as file: second = tmp[1] * tmp[2] third = tmp[2] * tmp[0] #2*l*w + 2*w*h + 2*h*l - smallest = min(first,second, third) + smallest = min(first,second,third) #print(first,second, third, smallest) result = result + (2*first) + (2*second) + (2*third) + smallest print(result) diff --git a/2015/day2/part2.py b/2015/day2/part2.py new file mode 100644 index 0000000..c18ae81 --- /dev/null +++ b/2015/day2/part2.py @@ -0,0 +1,24 @@ +#!/bin/python3 + +import sys +from pprint import pprint + +input_f = sys.argv[1] + +result = 0 + +with open(input_f) as file: + for line in file: + tmp = line.rstrip().split('x') + tmp = list(map(int,tmp)) + first = tmp[0] * tmp[1] + second = tmp[1] * tmp[2] + third = tmp[2] * tmp[0] + #2*l*w + 2*w*h + 2*h*l + smallest = min(first,second,third) + #print(first,second, third, smallest) + tmp.sort() + rib = tmp[0]+tmp[0]+tmp[1]+tmp[1] + bow = tmp[0]*tmp[1]*tmp[2] + result = result + rib + bow + print(result)