Advent of Code 2022 https://adventofcode.com/2022
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.

day1-1.py 454B

1234567891011121314151617
  1. # https://adventofcode.com/2022/day/1
  2. def main():
  3. with open("input1.txt", "r") as file:
  4. indata = file.read()
  5. elves = indata.split("\n\n")
  6. elf_cals = []
  7. for i, elf in enumerate(elves):
  8. cal_lines = [int(x) for x in elf.split("\n")]
  9. elf_cals.append((i,sum(cal_lines)))
  10. elf_cals_sorted = sorted(elf_cals, reverse=True, key=lambda x: x[1])
  11. print(elf_cals_sorted[0])
  12. if __name__ == "__main__":
  13. main()