
Hi all, I learn Haskell and i try to solve questions from SPOJ. Currently, i try to solve problem *Sorting Bank Accounts*http://www.spoj.com/problems/SBANK/ Here is my code: *import qualified Data.Map as M* * * *extractTest []=[]* *extractTest (x:xs)=(take n xs):(extractTest (drop (n+1) xs)) where* * n=read x* * * *emp=M.empty* * * *collect m []=m* *collect m (x:xs)* * |M.member x m =collect (M.insert x (amount+1) m) xs* * |otherwise=collect (M.insert x 1 m) xs* * where* * Just amount=M.lookup x m* * * *getList m=map (\(x,k)->x++" "++(show k)) (M.toList m)* *f x=unlines$(getList (collect emp x))++[""]* *main=getLine>>=(\x->interact$unlines.map f.take (read x).extractTest.lines) * * * The problem is that i can't finish it during 7 sec. So i want to know is there more quick solution/method for this problem. Thanks, Nadav