-
-
Save chrissound/fc3c72dea60abdbe70f11974f13c8f2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Control.Applicative | |
| import Control.Monad | |
| import System.IO | |
| import Debug.Trace | |
| getMultipleLines :: Int -> IO [String] | |
| getMultipleLines n | |
| | n <= 0 = return [] | |
| | otherwise = do | |
| x <- getLine | |
| xs <- getMultipleLines (n-1) | |
| let ret = (x:xs) | |
| return ret | |
| getCountRepeatingChars :: String -> Int | |
| getCountRepeatingChars [] = 0 | |
| getCountRepeatingChars (_:[]) = 0 | |
| getCountRepeatingChars (x:(xs@y:z)) | |
| | x == y = 1 + rest | |
| | otherwise = rest | |
| where rest = getCountRepeatingChars (y : z) | |
| main :: IO () | |
| main = do | |
| linesToGet <- getLine | |
| a <- getMultipleLines (read linesToGet) | |
| let repeatChars = map getCountRepeatingChars a | |
| mapM_ print repeatChars |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment