rewrite/js: day one part one
This commit is contained in:
parent
d8bfa2e21b
commit
970ecd65a9
3 changed files with 28 additions and 0 deletions
3
one/.prettierrc
Normal file
3
one/.prettierrc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"arrowParens": "avoid"
|
||||||
|
}
|
13
one/one.js
Normal file
13
one/one.js
Normal 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
12
one/package.json
Normal 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"
|
||||||
|
}
|
Loading…
Reference in a new issue