You are viewing a single comment's thread. Return to all comments →
Simple solution in haskell using the group function:
import Data.List formatGroup :: String -> String formatGroup cs | length cs == 1 = [head cs] | otherwise = head cs : (show . length) cs compress :: String -> String compress s = concatMap formatGroup $ group s main = do s <- getLine putStrLn (compress s)
Seems like cookies are disabled on this browser, please enable them to open this website
String Compression
You are viewing a single comment's thread. Return to all comments →
Simple solution in haskell using the group function: