Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re (tilly) 1: (Golf as well): List of Partitions

by tilly (Archbishop)
on May 06, 2001 at 16:32 UTC ( #78344=note: print w/replies, xml ) Need Help??

in reply to (Golf as well): List of Partitions

Occasionally I wish I hadn't given away most of my math books, this is one of those occasions. I had a book with lots about partitions in it, but I long ago gave it away. However this problem is quite doable. The trick is to make P a function of 2 variables, first the number n you are interested in partitioning, and then the number i that is the largest number you are willing to partition it into.

With that tip, here is an answer in 90 characters:

sub P { my($n,$i)=@_;$i||=$n;$i-1?map{my$c=$_;map[($i)x$c,@$_],P($n-$c*$i,$i-1 +)}0..$n/$i:[(1) x$n] }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://78344]
[Corion]: thezip: Yeah - we have "CAP", but that means "Change Ablauf Plan" (Change Sequence Plan). Likely there is a true ITIL name for this too.
[Corion]: While I'm not really a fan of ITIL, it certainly is better than nothing and it at least provides a common vocabulary, so if you have ITIL somewhere at your disposal, it might be worth a look
[Corion]: Hmm - that should be somewhere in the "Release Deployment Plan", but I don't find a good English link (nor a good German one ;) )
[thezip]: My project manager is asking "Why do we need this?" Ahem...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2017-02-23 17:55 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (350 votes). Check out past polls.