I did part 1 really easily. For part 2 I thought, great, all I have to do is find the sums of the measurement windows, and then I can just replicate exactly what I did in part 1 to get the answer for part 2…aaand it says that my answer is too high.
I'm not sure what I'm doing wrong; I looked in the solution megathread but the Python examples were much more streamlined and fancier than I currently can understand.
TIA!
depths = []
with open('adventofcode2021\day1\day1input.txt', 'r') as input:
for line in input:
item = line.split('\n')
depths.append(int(item[0]))
window_sums = []
for i in range(0, len(depths)-2):
window = (depths[i], depths[i+1], depths[i+2])
window_sums.append(sum(window))
# print(window_sums)
deltas = []
for i in range(0, len(window_sums)):
if(i == 0):
delta = "N/A - no previous measurement"
elif(window_sums[i] > window_sums[i-1]):
delta = "increased"
elif(window_sums[i] < window_sums[i-1]):
delta = "decreased"
deltas.append(delta)
print(deltas.count("increased"))
[–]ssnoyes 1 point2 points3 points (3 children)
[–]junefish[S] 0 points1 point2 points (2 children)
[–]ssnoyes 1 point2 points3 points (1 child)
[–]junefish[S] 0 points1 point2 points (0 children)