CSES - Datatähti 2021 alku - Results
Submission details
Task:Sanalista
Sender:Otju
Submission time:2020-10-07 18:49:01 +0300
Language:Node.js
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.46 sdetails
#2ACCEPTED0.46 sdetails
#3ACCEPTED0.46 sdetails

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