123456789101112131415161718192021222324252627282930 |
- def main():
- """ Consider three-depth windows instead of individual depths:
- 199 A
- 200 A B
- 208 A B C
- 210 B C D
- 200 E C D
- 207 E F D
- 240 E F G
- 269 F G H
- 260 G H
- 263 H
- For each window in the list, determine whether it's deeper than the previous window.
- There is no previous depth for the first entry.
- Output the total number of times the depth increased.
- """
- with open("aoc1-1.txt", "r") as file:
- depths = file.readlines()
- depths = [int(el.strip()) for el in depths]
- prev = 999999999
- increases = []
- for i in range(len(depths)-2):
- window = depths[i] + depths[i+1] + depths[i+2]
- increases.append(1 if window > prev else 0)
- prev = window
- print(sum(increases))
-
-
- if __name__ == "__main__":
- main()
|