diff --git a/2022/.gitignore b/2022/.gitignore new file mode 100644 index 0000000..63ff173 --- /dev/null +++ b/2022/.gitignore @@ -0,0 +1 @@ +*.input diff --git a/2022/day1.ts b/2022/day1.ts new file mode 100644 index 0000000..005e176 --- /dev/null +++ b/2022/day1.ts @@ -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); diff --git a/readme.md b/readme.md index 47ad1b5..2a72c9e 100644 --- a/readme.md +++ b/readme.md @@ -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)