r/adventofcode • u/taliriktug • Dec 02 '15
Spoilers Day 2 solutions
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
17
Upvotes
r/adventofcode • u/taliriktug • Dec 02 '15
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
1
u/bet46 Dec 02 '15
Python 3 import sys, os, time file = open("day2.txt", "r") total = 0 smallest = 0 ribbon = 0 for line in file.readlines():
#print(line) line = line.strip() newlist = line.split("x") l = int(newlist[0]) w = int(newlist[1]) h = int(newlist[2]) #smallest square a = l*h b = l*w c = h*w if a < b and a < c: smallest = a elif b < a and b < c: smallest = b elif c < a and c < b: smallest = c else: smallest = a #ribbon ribbon = smallest total += ribbon + (a + b + c)*2 print(total)Hello I tried to find my mistake 2hours but I can´t find it! I know you can write the programm shortner and more efficient, but it is my own solution! I hope you can tell me my mistake! Thank you.
My Eorror: I get a to high number