CSES - Datatähti 2021 alku - Results
Submission details
Task:Sanalista
Sender:ZakkeX
Submission time:2020-09-28 11:43:34 +0300
Language:Haskell
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails

Compiler report

input/code.hs:4:21: warning: [-Wtype-defaults]
    * Defaulting the following constraints to type `Integer'
        (Eq a0) arising from a use of `==' at input/code.hs:4:21-208
        (Num a0) arising from the literal `0' at input/code.hs:4:21
        (Integral a0) arising from a use of `mod' at input/code.hs:4:33-35
    * In the expression:
        0 ==
            ((flip mod) 2
               $ snd
                   $ foldl
                       (\ (prev, count) char
                          -> if prev /= char && mod count 2 /= 0 then
                                 (prev, count)
                             else
                                 if prev /= char then (char, 1) else (char, count + 1))
                       ('a', 0)
                       string)
      In an equation for `parillinen':
          parillinen string
            = 0 ==
                  ((flip mod) 2
                     $ snd
                         $ foldl
                             (\ (prev, cou...

Code

import Data.List

parillinen :: String -> Bool
parillinen string = 0 == ((flip mod) 2 $ snd $ foldl (\(prev, count) char -> if prev /= char && mod count 2 /= 0 then (prev, count) else if prev /= char then (char, 1) else (char, count + 1)) ('a', 0) string)

main = do
    input <- getContents
    print $ length $ filter parillinen $ map sort $ tail $ lines input

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