Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2015-07-06 10:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (72 votes), past polls