Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Largest Sum of Consecutive Integers

by aquarium (Curate)
on Aug 30, 2006 at 22:28 UTC ( #570494=note: print w/replies, xml ) Need Help??


in reply to Re: Largest Sum of Consecutive Integers
in thread Largest Sum of Consecutive Integers

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
  • Comment on Re^2: Largest Sum of Consecutive Integers

Replies are listed 'Best First'.
Re^3: Largest Sum of Consecutive Integers
by JadeNB (Chaplain) on Oct 13, 2008 at 21:48 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.
    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.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://570494]
help
Chatterbox?
[jdporter]: let me google that for me ;-)
[jdporter]: hex points explicitly to oct, which does the job. :-D
[jdporter]: omg, I f love Perl!
[choroba]: say unpack 'H*', pack 'B*', $mask =~ /0b([01]+)/;
[choroba]: use C instead of H to get the decimal number
[erix]: ( no love like f love )
[choroba]: f* love

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2018-02-20 16:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (272 votes). Check out past polls.

    Notices?