Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Near equal partitions.

by ELISHEVA (Prior)
on Jan 14, 2011 at 04:58 UTC ( #882284=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub part {
      my ($n, $m) = @_;
    ...
      $parts[$i++]++ while $r--;
      return @parts;
    }
    
  2. or download this
    sub part {
      my ($n, $m) = @_;
    ...
      my $q = ($n-$r)/$m; # avoid int($n/$m) to prevent fp rounding errors
      return ($q+1) x $r, ($q) x ($m-$r);
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2020-01-24 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?