"""Advent day 1, challenge 2 Count the number of times the input number is higher than the previous one, but do a 3 day sliding window """ depths = [] with open("1_1_input.txt") as f: depths = [int(line) for line in f.readlines()] sliding_sums = [sum(depths[i:i+3]) for i in range(len(depths) - 2)] prev_depth = None n_increased = 0 for depth in sliding_sums: if (prev_depth is not None and depth > prev_depth): n_increased += 1 prev_depth = depth print(n_increased)