Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.List ( group, sort, transpose )
- import GHC.Base (join)
- import Control.Arrow ( Arrow((&&&)) )
- f a= map $ join.map (\x->[length x:head x] <> replicate (length x - 1) [0]).group.a
- f2 x= map (length &&& head).group.map init.sort.filter ((/=0).last).join.f id $ transpose $ f (map (:[])) x
- main = readLn >>= print.f2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement