rewrite/js: day one part one

main
Zynh0722 2023-12-03 04:59:27 -08:00
parent d8bfa2e21b
commit 970ecd65a9
3 changed files with 28 additions and 0 deletions

3
one/.prettierrc Normal file
View File

@ -0,0 +1,3 @@
{
"arrowParens": "avoid"
}

13
one/one.js Normal file
View File

@ -0,0 +1,13 @@
import fs from "node:fs";
let data = fs.readFileSync("input", "utf8");
let lines = data
.split("\n")
.map(l => l.split("").filter(c => +c == c))
.map(l => [l[0], l[l.length - 1]])
.map(l => l.join(""))
.map(n => Number(n))
.reduce((acc, n) => acc + n);
console.log(lines);

12
one/package.json Normal file
View File

@ -0,0 +1,12 @@
{
"name": "one",
"version": "1.0.0",
"description": "",
"main": "one.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"type": "module"
}