Skip to content

Instantly share code, notes, and snippets.

@kejadlen
Created June 9, 2017 22:25
Show Gist options
  • Save kejadlen/6acab829f8915e0fa72b5a2704325869 to your computer and use it in GitHub Desktop.
Save kejadlen/6acab829f8915e0fa72b5a2704325869 to your computer and use it in GitHub Desktop.
import Data.List
pairs xs = zip xs (tail xs)
repeatingPairs xs = filter (\(x,y) -> x == y) $ pairs xs
hasRepeatingPairs :: String -> Bool
hasRepeatingPairs xs = any (\pair -> length (elemIndices pair rps) >= 2) rps
where rps = repeatingPairs xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment