Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://710312]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2017-11-24 17:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (351 votes). Check out past polls.

    Notices?