Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

123456789101112131415161718
  1. def main():
  2. """ For each depth in the list, determine whether it's deeper than the previous depth.
  3. There is no previous depth for the first entry.
  4. Output the total number of times the depth increased.
  5. """
  6. with open("aoc1-1.txt", "r") as file:
  7. depths = file.readlines()
  8. depths = [int(el.strip()) for el in depths]
  9. prev = 999999999
  10. increases = []
  11. for depth in depths:
  12. increases.append(1 if depth > prev else 0)
  13. prev = depth
  14. print(sum(increases))
  15. if __name__ == "__main__":
  16. main()