aboutsummaryrefslogtreecommitdiff
path: root/challenge-139/abigail/node/ch-1.js
blob: f45be6188cc0da2b188281ba71fd71772adbc71a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/local/bin/node

//
// See ../README.md
//

//
// Run as: node ch-1.js < input-file
//

  require ('readline')
. createInterface ({input: process . stdin})   
. on              ('line', line => {
    console . log (line . match (/[0-9]+/gi) . reduce ((sorted, _, i, list) => {
        if (i > 0 && list [i - 1] > list [i]) {sorted = 0}
        return sorted},
        1)
    )
})