Day 1 late-night-phone-solution
This commit is contained in:
parent
37487619bb
commit
1665f447e8
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);
|
Loading…
Reference in a new issue