[Haskell-cafe] Re: Euler 201 performance mystery

2008-07-16 Thread apfelmus
[EMAIL PROTECTED] wrote: Dear Group, I've spend the last few days figuring out the solution to Euler Problem 201 in haskell. I first tried a relatively elegant approach based on Data.Map but the performance was horrible. I never actually arrived at the answer. I then rewrote the same

[Haskell-cafe] Re: Euler 201 performance mystery

2008-07-16 Thread apfelmus
apfelmus wrote: In other words, we have now calculated the more efficient program euler201 = map snd . filter ((==50) . fst) . subsums $ squares where subsums [] = singleton (0,0) subsums (x:xs) = map (\(n,s) - (n+1,s+x)) (subsums xs) `union` subsums xs I forgot something