Day 1 late-night-phone-solution
This commit is contained in:
parent
37487619bb
commit
1665f447e8
3 changed files with 21 additions and 0 deletions
1
2022/.gitignore
vendored
Normal file
1
2022/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.input
|
19
2022/day1.ts
Normal file
19
2022/day1.ts
Normal 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);
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue