Partitions of an integer

Damien Wyart damien.wyart at free.fr
Mon Jul 26 05:48:52 EDT 2004


* Nick J Chackowsky <mediocre_person at hotmail.com> in comp.lang.python:
> Wrote a python script to find the partitions of an integer (a list of 
> all the ways you can express n as a sum of integers). For example, the 
> partitions of 5 are
> 5
> 4+1
> 3+2
> 2+2+1
> 3+1+1
> 2+1+1+1
> 1+1+1+1+1

There have been good answers to your questions in the thread, so I won't
give more Python code here. I just wanted to point out this draft from
Knuth where many details about the theory of partitions and the related
algorithms can be found. I guess this will be of interest for all
contributors of the thread if they do not know this document already.

<http://www-cs-faculty.Stanford.EDU/~knuth/fasc3b.ps.gz>

-- 
DW



More information about the Python-list mailing list