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

15 lines
732 B
Python

from calories.file.calorie_list import CalorieList
if __name__ == "__main__":
elves = CalorieList("./input/day1/input.lst").parse_file()
for elf in elves:
print(f"Elf {elf} has calories: {elf.get_inventory_calories()}")
elves.sort(key=lambda x: x.get_inventory_calories(), reverse=True)
print(f"Most calories has: {elves[0]} with {elves[0].get_inventory_calories()} calories in their inventory!")
print(f"The top 3 calorie elves are: {elves[0]} ({elves[0].get_inventory_calories()}), "
f"{elves[1]} ({elves[1].get_inventory_calories()}) and "
f"{elves[2]} ({elves[2].get_inventory_calories()})")
print(f"Their total is: {sum([x.get_inventory_calories() for x in elves[:3]])}")