You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

aoc1-1.py 568B

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