-
Notifications
You must be signed in to change notification settings - Fork 0
/
day01_1.js
23 lines (21 loc) · 837 Bytes
/
day01_1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
console.log("---");
import { readLines } from "https://deno.land/[email protected]/io/bufio.ts";
import { range } from "https://deno.land/x/[email protected]/range.mjs";
import { slidingWindows } from "https://deno.land/[email protected]/collections/mod.ts";
import count from "https://deno.land/x/[email protected]/src/collection/count.ts";
// dconst all = [];
// for await (let line of readLines(Deno.stdin)) {
// console.log({ line });
// all.push(line.split("").map((v) => parseInt(v, 10)));
// }
const all = (await Deno.readTextFile("./resources/input01.txt"))
.trim()
.split("\n\n");
const sums = all.map((e) => {
const w = e.split("\n").map((i) => parseInt(i, 10));
// console.log(w);
return w.reduce((acc, s) => acc + s, 0);
});
sums.sort((a, b) => b - a);
console.log(sums[0] + sums[1] + sums[2]);
//console.log({ sums, all });