Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Split range 0 to M into N non-overlapping (roughly equal) ranges.

by Corion (Patriarch)
on Mar 12, 2011 at 18:12 UTC ( [id://892846]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    ($N,$M)=@ARGV;
    ($step,$s)=(int$M/$N,0);
    puhs @ranges, [$M-$step,$M],$M-=$step
        while($M and ($M > 2*$step or $M%$step==0));
    print 'Last step oversized by ',$M-$step
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-04-19 15:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found