Day 01&02

This commit is contained in:
Kevin Baensch 2022-12-02 11:42:44 +01:00
commit a3fefe26a6
6 changed files with 4836 additions and 0 deletions

View file

@ -0,0 +1,19 @@
const input = Deno.readTextFileSync('./input.txt');
const elveCal = [];
let curElve = 0;
let curCal = 0;
for (const line of input.split('\n')) {
if (line === '') {
elveCal[curElve] = curCal;
curCal = 0;
curElve += 1;
} else {
curCal += parseInt(line);
}
}
elveCal.sort().reverse();
console.log('Top Score:\t', elveCal[0]);
const top3 = elveCal.slice(0, 3).reduce((prev, cur) => prev + cur, 0);
console.log('Top three sum:\t', top3);

2236
src/01_Calories/input.txt Normal file

File diff suppressed because it is too large Load diff