Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.List
- import Data.Function
- merge :: [a] -> [a] -> [a]
- merge xs [] = xs
- merge [] ys = ys
- merge (x:xs) (y:ys) = y : x : merge xs ys
- main :: IO ()
- main = do
- input <- getContents
- mapM_ putStrLn . foldl1 merge $
- sortBy (on compare length) (group . sort $ lines input)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement