main.py 920 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import os, sys
  2. task_dir = os.path.dirname(__file__)
  3. sys.path.append(f"{task_dir}/..")
  4. from get_tasks import get_input
  5. measures, example = get_input(task_dir, 1)
  6. # print(example)
  7. def part1(input):
  8. counter = 0
  9. temp = max(int(m) for m in input)
  10. for measure in input:
  11. if int(measure) > temp:
  12. counter += 1
  13. temp = int(measure)
  14. print("The answer of part1 is:", counter)
  15. def check_part1(example):
  16. part1(example)
  17. def part2(input):
  18. input = [int(m) for m in input]
  19. counter = 0
  20. temp = sum(input[0:3])
  21. for ind in range(len(input) - 2):
  22. if sum(input[ind : ind + 3]) > temp:
  23. counter += 1
  24. temp = sum(input[ind : ind + 3])
  25. print("The answer of part2 is:", counter)
  26. def check_part2(example):
  27. part2(example)
  28. if __name__ == "__main__":
  29. check_part1(example)
  30. part1(measures)
  31. check_part2(example)
  32. part2(measures)