aboutsummaryrefslogtreecommitdiff
path: root/challenge-091/abigail/node/ch-1.js
blob: 898e085e2b8b420c0d17bdf2a27a6ecf7a9c4284 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
;