in reply to Largest Sum of Consecutive Integers

Have you considered using Set::Array? There are a few functions in there for manipulating arrays that might be of use to you.

Eric

  • Comment on Re: Largest Sum of Consecutive Integers

Replies are listed 'Best First'.
Re^2: Largest Sum of Consecutive Integers
by aquarium (Curate) on Aug 30, 2006 at 22:28 UTC
    the largest sum is always going to be: add up all positive integers in the array and exclude negatives. as adding is communicative, order of the array and sequence of the add operation doesn't make any difference.
    the hardest line to type correctly is: stty erase ^H
      the largest sum is always going to be: add up all positive integers in the array and exclude negatives. as adding is communicative, order of the array and sequence of the add operation doesn't make any difference.
      While this certainly gives the largest sum of a sub(multi)set of the entries of the array, it needn't satisfy the conditions of the problem, since that required the summands to be consecutive terms of the array. (Incidentally, addition is commutative.)