blob: 4e9353f3aff0452ae0d39c91b65c41021737f9d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#!/usr/local/bin/node
//
// See ../README.md
//
//
// Run as: node ch-1.js < input-file
//
require ('readline')
. createInterface ({input: process . stdin})
. on ('line', line => {
let numbers = {}
let input = [... line . matchAll (/[1-9][0-9]*/g)] . map (_ => + _ [0])
input . forEach (n => {
if (!numbers [n]) {
numbers [n] = 1
}
else {
numbers [n] ++
}
})
for (let n in numbers) {
if (numbers [n] % 2 == 1) {
console . log (n)
}
}
})
|