Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Generator of integer partitionts of n

by ikegami (Patriarch)
on Aug 28, 2004 at 06:34 UTC ( [id://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);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-25 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found