Skip to content

Instantly share code, notes, and snippets.

@mwotton
Created January 18, 2010 06:26
Show Gist options
  • Save mwotton/279825 to your computer and use it in GitHub Desktop.
Save mwotton/279825 to your computer and use it in GitHub Desktop.
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