import { readFileSync } from 'fs'; import { join } from 'path'; const fileString = readFileSync(join(__dirname, "input"), 'utf-8'); const rawCalories = fileString.split("\n\n"); var parsedCalories = []; for (const calorieData of rawCalories) { var total: number = 0; const calorieStringArray = calorieData.split("\n"); for (const calorie of calorieStringArray) { const c: number = +calorie; total += c; } parsedCalories.push(total); } parsedCalories = parsedCalories.sort((n1, n2) => n1 - n2); console.log(parsedCalories[parsedCalories.length - 1]); console.log(parsedCalories[parsedCalories.length - 1] + parsedCalories[parsedCalories.length - 2] + parsedCalories[parsedCalories.length - 3]);