a.py 900 B

123456789101112131415161718192021222324252627282930313233
  1. import os, argparse
  2. def solve_task(filename):
  3. with open(filename) as infile:
  4. all_elves = []
  5. current_elf = 0
  6. highest = 0
  7. for raw_line in infile:
  8. line = raw_line.rstrip()
  9. if line != "":
  10. current_elf += int(line)
  11. else:
  12. all_elves.append(current_elf)
  13. highest = max(current_elf, highest)
  14. current_elf = 0
  15. print(f"Highest ammount {highest}")
  16. os.system("pause")
  17. def parse_arguments():
  18. parser = argparse.ArgumentParser(description="Script that solves the case",epilog="Have a nice day!")
  19. parser.add_argument('filename', nargs='?', default="example.txt", help='Input file')
  20. args = parser.parse_args()
  21. return args
  22. def main():
  23. args = parse_arguments()
  24. solve_task(args.filename)
  25. if __name__ == "__main__":
  26. main()