Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Near equal partitions.

by ELISHEVA (Prior)
on Jan 14, 2011 at 04:58 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://882284]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found