Advertisement
Guest User

Untitled

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