help with code for combinations/permutations

Andreas Jung andreas at andreas-jung.com
Wed Jan 17 15:39:32 EST 2001


On Wed, Jan 17, 2001 at 06:37:44PM +0000, Bryan Webb wrote:
> Thanks to all that responded.
> 
> I wasnt as clear as I should have been. (as usual)
> I really need to come up with all the possible sums of the numbers in the
> list ie. 1 , sum(1 + 2), sum(1 + 2 + 3) ,sum( 1+2+4),sum( 1 + 3) and so on.

Ok, now you are talking about subsets but not of permutations. Because the
order of the elements does not matter there are much fewer possibilities. I
suggest to make an example by hand: take a set of 4 elements and generate all
subsets by hand. Then you will learn how such an algorithm should work.

Andreas 




More information about the Python-list mailing list