Day 01&02
This commit is contained in:
commit
a3fefe26a6
6 changed files with 4836 additions and 0 deletions
19
src/01_Calories/Calories.ts
Normal file
19
src/01_Calories/Calories.ts
Normal 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
2236
src/01_Calories/input.txt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue