01_1
This commit is contained in:
commit
731cd6422f
File diff suppressed because it is too large
Load Diff
|
@ -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);
|
|
@ -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"
|
||||
}
|
Loading…
Reference in New Issue