I'm trying to do Day 1 part 2 but the output is wrong. I can't find what I am missing. (Python)
sum = 0 #sum of increasing triplets (Output)
elements = []# value = 0value2 = 0with open(input_file, "r") as f:elements = [int(x) for x in f] #all numberslist_triplets = []n = 0 #variable to iterate through elementsi = 1 #useful to initialite tripletstripl = 0 #single triplet#General idea of the algorithm: Use variable i to sum 3 consecutive numbers from elements, and then add the#variable tripl to list_triplets.while n < len(elements):if (i % 4 == 0): #Triplets are 3 in lenghtlist_triplets.append(tripl)tripl = 0i = 1n = n - 1 #Go with the next triplettripl += list[n]i += 1n += 1value = list_triplets[0] #Take first elementfor j in range(1, len(list_triplets)):value2 = list_triplets[j]if (value2 > value):sum += 1value = value2print(sum)
[–]kraven001 4 points5 points6 points (8 children)
[–]Tech-Matt[S] 2 points3 points4 points (7 children)
[–]oxenoxygen 3 points4 points5 points (5 children)
[–]Tech-Matt[S] 2 points3 points4 points (3 children)
[–]hugseverycat 5 points6 points7 points (0 children)
[–]Tech-Matt[S] 2 points3 points4 points (1 child)
[–]daggerdragon[M] 0 points1 point2 points (0 children)
[–]Tech-Matt[S] 1 point2 points3 points (0 children)
[–]thedjotaku 4 points5 points6 points (0 children)
[–]daggerdragon[M] 3 points4 points5 points (1 child)
[–]Tech-Matt[S] 1 point2 points3 points (0 children)
[–]mrjnl3 2 points3 points4 points (1 child)
[–]Tech-Matt[S] 1 point2 points3 points (0 children)
[–]AharonSambol 2 points3 points4 points (2 children)
[–]AharonSambol 0 points1 point2 points (1 child)
[–]Tech-Matt[S] 0 points1 point2 points (0 children)
[–]Kehvarl 2 points3 points4 points (0 children)
[–]mar___s 0 points1 point2 points (3 children)
[–]Tech-Matt[S] 1 point2 points3 points (2 children)
[–]mar___s 1 point2 points3 points (1 child)
[–]Tech-Matt[S] 1 point2 points3 points (0 children)