Task: | Sanalista |
Sender: | Otju |
Submission time: | 2020-10-07 18:49:01 +0300 |
Language: | Node.js |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.46 s | details |
#2 | ACCEPTED | 0.46 s | details |
#3 | ACCEPTED | 0.46 s | details |
Code
const readline = require('readline') const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false }) const lines = [] let amount rl.on('line', (line) => { if (!amount) { amount = parseInt(line) } else { lines.push(line) } if (amount && lines.length === amount) { rl.close() } }) rl.on('close', () => { const evenOnes = lines.map(line => { let isEven = true const charObjs = []; [...line].forEach(char => { charObj = charObjs.find(item => item.letter === char) if (charObj) { charObj.count++ } else { charObjs.push({ letter: char, count: 1 }) } }) charObjs.forEach(item => { if (item.count % 2 !== 0) { isEven = false } }) return isEven }) console.log(evenOnes.filter(item => item).length) })
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1000 korvata sopimusaika nuhatartunta korttiautomaatti ... |
correct output |
---|
15 |
user output |
---|
15 |
Test 2
Verdict: ACCEPTED
input |
---|
1000 pub hansikaslokero erikoisvalmisteinen unijukka ... |
correct output |
---|
42 |
user output |
---|
42 |
Test 3
Verdict: ACCEPTED
input |
---|
1000 haapalastu toipumisaika mustalaiskieli taidelainaamo ... |
correct output |
---|
70 |
user output |
---|
70 |