From: Jesse Merriman Date: 2007-07-16T10:19:45+09:00 Subject: Re: [Solution][QUIZ] Maximum Sub-Array (#131) On Sunday 15 July 2007 17:17, Michael Glaesemann wrote: > Here's a solution which iterates over the array just once. Looks like > I came up with a variant of the algorithm presented by Henrik Schmidt- > M�ller, though I'm storing the local max sub array rather than just > its delimiting indices. I'm not happy with the calls to slice > (especially as they require calculating the size of the array), but > I'm pleased that I came up with a solution using recursion. > > Not to be the downer who points out everyone's problems, but here's a bug: irb(main):008:0> arr = [46, -8, 43, -38, -34, -14, 10, -26, -9, -19, -36, -6, -20, -4, -23, -25, 48, -22, 22, 5, -21, -33, 37, 39, -22, 11, -44, -40, -37, -26] irb(main):009:0> arr.max_sub_array => [37, 39, 10] That sequence does not appear in arr. -- Jesse Merriman jessemerriman@warpmail.net http://www.jessemerriman.com/