Created
January 18, 2010 06:26
-
-
Save mwotton/279825 to your computer and use it in GitHub Desktop.
This file contains 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 qualified Data.ByteString.Char8 as BS | |
import Data.Ord | |
import Data.List | |
import Data.Function | |
import System | |
most_anagrams ws = sortBy (flip $ comparing length) $ groupBy (\a b -> fst a == fst b) $ sortBy (comparing fst) $ zip (map BS.sort ws) ws | |
main = do (arg:_) <- getArgs | |
d <- BS.readFile arg | |
print $ take 3 $ most_anagrams $ BS.lines d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment