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((&&&)) )
- import Data.Traversable (for)
- import Control.Monad (replicateM)
- import Data.Char ( digitToInt )
- f a= map $ join.map (\x->[length x:head x] <> replicate (length x - 1) [0]).group.a
- f2 x= map (length &&& head).group.sort.map (reverse.sort.init).filter ((/=0).last).join.f id $ transpose $ f (map (:[])) x
- ff n = replicateM n getLine
- main = do
- x <- getLine
- matr <- ff (read $ takeWhile (/=' ') x )
- print $ f2 $ (map.map) digitToInt matr
Advertisement
Add Comment
Please, Sign In to add comment