[Haskell-cafe] Is this haskelly enough?

Eric Mertens emertens at gmail.com
Tue Jul 17 17:35:29 EDT 2007


James,

In my earlier post I mentioned that you should find a dynamic
programming approach to this problem. My solution is presented below,
so you've been warned if you are still working this out:


=== READ ABOVE ===

import Data.List (foldl')

solve = snd . foldl' aux (0, 0)
  where
  aux (cur, best) x = (max 0 cur', max best cur')
    where
    cur' = cur + x


-- 
Eric Mertens


More information about the Haskell-Cafe mailing list