Advertisement
Guest User

[2015-07-03] Challenge #221 [Hard] Poetry in a haystack

a guest
Jul 3rd, 2015
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Main where
  2.  
  3. import Data.List as L
  4. import Data.Ord
  5. import Data.ByteString.Char8 as B
  6.  
  7. isVowel :: Char -> Bool
  8. isVowel c = B.any (c ==) $ B.pack "aeiou"
  9.  
  10. consonantGrouping :: B.ByteString -> Bool
  11. consonantGrouping = L.any ((>= 4) . B.length) . splitWith isVowel
  12.  
  13. vowelGrouping :: B.ByteString -> Bool
  14. vowelGrouping = L.any ((> 3) . B.length) . splitWith (not . isVowel)
  15.  
  16. isGibberish :: B.ByteString -> Bool
  17. isGibberish line = let cGCoefficient = L.any consonantGrouping     $ B.words line
  18.                        vGCoefficient = L.any vowelGrouping         $ B.words line
  19.                        nVCoefficient = L.any (not . B.any isVowel) $ B.words line
  20.                    in nVCoefficient || vGCoefficient || cGCoefficient
  21.  
  22. main :: IO ()
  23. main = B.interact $ B.unlines . L.filter (not . isGibberish) . B.lines
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement