26 lines
720 B
Python
26 lines
720 B
Python
import os
|
|
import aocd
|
|
import pandas as pd
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
puzzle_input = aocd.get_data(day=1, year=2022)
|
|
|
|
puzzle_input_list = str(puzzle_input).split('\n')
|
|
elf_df = pd.DataFrame(columns=['Name','Total Calories'])
|
|
|
|
reindeer_total = 0
|
|
elf_id = 0
|
|
|
|
for calorie_count in puzzle_input_list:
|
|
try:
|
|
reindeer_total = reindeer_total + int(calorie_count)
|
|
except:
|
|
elf_id = elf_id + 1
|
|
elf_name = f'elf_{elf_id}'
|
|
elf_df.loc[len(elf_df.index)] = elf_name,reindeer_total
|
|
reindeer_total = 0
|
|
|
|
top_3_chonkers = elf_df['Total Calories'].nlargest(3).sum(numeric_only=True)
|
|
|
|
print(f'The three chonkiest elves ate {top_3_chonkers:,} calories, what heccin chonkers.') |