Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by ELISHEVA (Prior)
on Mar 12, 2011 at 19:40 UTC ( #892856=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub ranges_beth2 {
      my ($M, $N) = @_;
    ...
      return [ map { my $iStart=$iEnd; [$iStart, ($iEnd+=$_) - 1]
                   } (($q+1) x $r, ($q) x ($N-$r)) ];
    }
    
  2. or download this
    ---------------------------
     0 : from       0 to 9999997 (9999998)
    ...
     1 : from 2500000 to 4999999 (2500000)
     2 : from 5000000 to 7499998 (2499999)
     3 : from 7499999 to 9999997 (2499999)
    
  3. or download this
           s/iter   buk eli_ik
    buk      1.01    --   -8%
    ...
    buk    1.02/s    --   -4%
    eli_ik 1.06/s    4%    --
    
  4. or download this
    use Benchmark qw(cmpthese);
    
    ...
               , 'eli_ik' => sub { testRanges(\&ranges_beth2) }
             }
           );
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2020-10-24 18:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (246 votes). Check out past polls.

    Notices?