Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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()