Day 1 late-night-phone-solution

This commit is contained in:
Daniel Flanagan 2022-12-01 10:15:31 -06:00
parent 37487619bb
commit 1665f447e8
Signed by: lytedev
GPG Key ID: 5B2020A0F9921EF4
3 changed files with 21 additions and 0 deletions

1
2022/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.input

19
2022/day1.ts Normal file
View File

@ -0,0 +1,19 @@
const tDec = new TextDecoder();
const input = tDec.decode(Deno.readFileSync("day1.input"));
console.log(
"final",
input.split("\n\n").map((p) => {
const ns = p.split("\n").map((s) => {
const n = parseInt(s, 10);
console.log("inner", s, n);
return n;
}).filter((n) => !isNaN(n));
if (ns.length < 1) return NaN;
const n = ns.reduce((prev, cur) => prev + cur, 0);
console.log("oter", p, n, ns);
return n;
}).filter((n) => !isNaN(n)).sort().reverse(),
);
console.log(71924 + 69893 + 68589);

View File

@ -3,6 +3,7 @@
This repository is meant to contain all my [Advent of Code][aoc] code throughout
the years I've participated (to whatever extent).
- [2022](./2022)
- [2021](./2021)
- [2020](./2020)
- [2019](./2019)