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

Partitioning a set into parts of given sizes

by blokhead (Monsignor)
on Feb 28, 2006 at 22:19 UTC ( [id://533530]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use List::Util 'sum';
    sub partition {
    ...
        
        return 1;
    }
    
  2. or download this
    ## split 'a' through 'f' into blocks of sizes 3+2+1:
    my $iter = partition( [3,2,1], qw[a b c d e f]);
    ...
        print "[@$_] " for @parts;
        print $/;
    }
    
  3. or download this
    sub equipartition {
        my $parts = shift;
    ...
    
    my $iter = equipartition(4 => 1..16);
    ...
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://533530]
Approved by thor
Front-paged by Limbic~Region
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-20 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found