fork download
  1. import Data.Char
  2.  
  3. main = do
  4. putStrLn $ decode "W4E2H3"
  5. putStrLn $ decode "A12T3Y4"
  6.  
  7. decode :: String -> String
  8. decode = concat . map expand . split
  9.  
  10. expand :: String -> String
  11. expand "" = ""
  12. expand (x:xs) = take (read xs) $ repeat x
  13.  
  14. split :: String -> [String]
  15. split = words . tail . foldr fn ""
  16. where fn x acc = if (ord x < 48 || ord x > 57) then (' ':x:acc) else (x:acc)
Success #stdin #stdout 0s 8388607KB
stdin
Standard input is empty
stdout
WWWWEEHHH
AAAAAAAAAAAATTTYYYY