Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: sum of continues array

by themage (Friar)
on Sep 10, 2008 at 09:27 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://710312]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-24 05:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found