This commit is contained in:
Aelita4 2022-12-01 11:27:28 +01:00
commit 731cd6422f
Signed by: Aelita4
GPG Key ID: C217320B9C5FD53B
3 changed files with 2286 additions and 0 deletions

2237
day01/calories.txt Normal file

File diff suppressed because it is too large Load Diff

28
day01/index.js Normal file
View File

@ -0,0 +1,28 @@
import { readFileSync } from "fs";
const input = readFileSync("calories.txt", "utf-8");
const elves = [];
let elfNum = 0;
let isFirst = true;
input.split("\r\n").forEach(line => {
if(line === "") {
elfNum++;
isFirst = true;
} else {
if(isFirst) {
isFirst = false;
elves[elfNum] = parseInt(line);
} else elves[elfNum] += parseInt(line);
}
});
let maxCalories = 0;
elves.forEach(elf => {
if(elf > maxCalories) maxCalories = elf;
});
console.log(maxCalories);

21
package.json Normal file
View File

@ -0,0 +1,21 @@
{
"name": "advent-of-code",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Aelita4/advent-of-code-2022.git"
},
"keywords": [],
"type": "module",
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Aelita4/advent-of-code-2022/issues"
},
"homepage": "https://github.com/Aelita4/advent-of-code-2022#readme"
}