Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by jdrago999 (Pilgrim)
on Mar 15, 2011 at 04:34 UTC ( [id://893233]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -slw
    
    ...
        $_, @{ $ranges[ $_ ] },
        $ranges[ $_ ][ 1 ] - $ranges[ $_ ][ 0 ] + 1
        for 0 .. $#ranges;
    
  2. or download this
    john@e6510:~/Desktop$ ./ranges -N=1 -M=9999997
     0 : from       0 to 9999997 (9999998)
    ...
     3 : from 6000000 to 7999999 (2000000)
     4 : from 8000000 to 9999997 (1999998)
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found