Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: Generator of integer partitionts of n

by ikegami (Pope)
on Aug 28, 2004 at 06:34 UTC ( #386570=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Generator of integer partitionts of n
in thread Generator of integer partitionts of n

my @p; sub part { my ($a, $k, $n, $t) = @_; $n = 2*$k unless (defined($n)); $t = 0 unless (defined($t)); $p[$t] = $k; push(@$a, [ @p[1..$#p] ]) if $n == $k; for (my $j = $k<$n-$k ? $k : $n-$k; $j >= 1; $j--) { part($a, $j, $n-$k, $t+1); } } my $integer = ...; my @a; part(\@a, $integer); print(join(" ", @$_), "\n") foreach (@a);


Comment on Re^3: Generator of integer partitionts of n
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (13)
As of 2014-07-25 17:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (174 votes), past polls