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 ( #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? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2022-10-07 00:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (29 votes). Check out past polls.

    Notices?