Day 01: Calorie Counting
**
Elves are carrying food and we want to know who is carrying the most calories.
Journal
As this was my first exposure to the whole AOC thing, I didn't really know what to expect or what the format was or if it would be changing from day to day or what.
I solved this one completely in the Chrome dev tools console and didn't save it or anything (this was the general approach for the first few days).
I re-solved it here afterward as a dramatic reenactment.
Relevant Code
export const calculateCalorieCarriers = (loadInput: string) => {const { loads } = loadInput.split("\n").reduce((loadAccum, parcel) => {if (parcel) {// Add the calories to the current elfloadAccum.currentCalorieCount += +parcel;} else {// An empty line indicates we're starting a new elfloadAccum.loads.push(loadAccum.currentCalorieCount);loadAccum.currentCalorieCount = 0;}return loadAccum;},{ loads: [] as number[], currentCalorieCount: 0 });// Sort all the elves to figure out who is carrying the mostloads.sort((n1, n2) => n2 - n1);return loads;};
Output
Top test elves (0ms):
- 24000
- 11000
- 6000
Total: 41000
Top real elves (1ms):
- 71506
- 69368
- 68729
Total: 209603