help with code for combinations/permutations

Hans Nowak ivnowa at hvision.nl
Wed Jan 17 10:32:46 EST 2001


Bryan Webb wrote:
> 
> HI,
>     I have a list with 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 in it,
> I need to come up with all possible combinations of the numbers in the above
> list ie. 1 +2, 1+2+3, 1+2+3+4, 1+2+3+4+5 and so on.
>  I will have multiple lists to deal with, larger and smaller.
> Any help or ideas will be appreciated
> 
> Thanks
> Bryan Webb

This code might help you:

  http://tor.dhs.org/~zephyrfalcon/snippets/source/338.py

  http://tor.dhs.org/~zephyrfalcon/snippets/source/298.py

N.B. I do not maintain the snippets site anymore; you should be able to
find the same code, and possibly more, at the Python FAQTS site
(http://python.faqts.com).

--Hans Nowak



More information about the Python-list mailing list