From f1dbeec36d434e9e5281318caa12dafcd89a0232 Mon Sep 17 00:00:00 2001 From: Abigail Date: Sat, 19 Dec 2020 19:56:41 +0100 Subject: Nodejs solution for week 091/part 1 --- challenge-091/abigail/node/ch-1.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 challenge-091/abigail/node/ch-1.js diff --git a/challenge-091/abigail/node/ch-1.js b/challenge-091/abigail/node/ch-1.js new file mode 100644 index 0000000000..898e085e2b --- /dev/null +++ b/challenge-091/abigail/node/ch-1.js @@ -0,0 +1,15 @@ +// +// Read STDIN. Split on newlines, filter out empty lines, +// split each line on white space, then call "show" +// + require ("fs") +. readFileSync (0) // Read all. +. toString () // Turn it into a string. +. split ("\n") // Split on newlines. +. filter (_ => _ . length) // Filter out empty lines. +. map (_ => _ . replace (/([0-9])\1*/g, + (mtch, p1) => mtch . length + p1)) + // Replace +. map (_ => process . stdout . write (_ + "\n")) + // Print +; -- cgit