From 4ec3d4daaa7346889045eaed1fc92396533e6152 Mon Sep 17 00:00:00 2001 From: Tanishq Dubey Date: Sat, 3 Dec 2022 00:17:28 -0500 Subject: [PATCH] day 1 complete --- day1/solution.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/day1/solution.ts b/day1/solution.ts index b09b9ce..d6d8671 100644 --- a/day1/solution.ts +++ b/day1/solution.ts @@ -14,4 +14,7 @@ for (const calorieData of rawCalories) { parsedCalories.push(total); } -console.log(Math.max(...parsedCalories)); +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]);