CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:funkar
Submission time:2017-10-09 17:31:19 +0300
Language:Haskell
Status:COMPILE ERROR

Compiler report

input/code.hs:17:15:
    Couldn't match type `IO String' with `[Char]'
    Expected type: String
      Actual type: IO String
    In the first argument of `j', namely `getLine'
    In the first argument of `putStrLn', namely `(j getLine)'
    In a stmt of a 'do' block: putStrLn (j getLine)

Code

import Data.List


j :: String -> String
matches :: String -> Bool
dropFirst :: String -> String
matches xs = length xs /= length (nub xs)
j (xs)
  | not (matches xs) = xs
  | otherwise = j (dropFirst xs)
dropFirst x
  | length (head g) /= 1 = concat (tail g)
  | otherwise = head g ++ dropFirst (concat (tail g))
  where g = group x

main = do
  putStrLn (j getLine)