Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: sum of continues array

by themage (Friar)
on Sep 10, 2008 at 09:27 UTC ( #710312=note: print w/ replies, xml ) Need Help??


in reply to sum of continues array

hi sanku, what about this:

my @array=(1,2,3,4,-1,-2,-3,11,12,13); my @sums=(); my $last=0; map { push @sums, $last+$_ if $last>0 and $_>0; $last=$_; } @array; my $max=0; map {$max=$_ if $_>$max } @sums; print "Max sum: $max\n";


Comment on Re: sum of continues array
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://710312]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-08-01 12:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (13 votes), past polls