Permutations algoritm?
John Hunter
jdhunter at nitace.bsd.uchicago.edu
Fri Nov 15 17:27:38 EST 2002
>>>>> "sismex01" == sismex01 <sismex01 at hebmex.com> writes:
sismex01> Of a set of different items 'S', obtain all distinct
sismex01> subsets of 'n' items where all items in the subset are
sismex01> different.
If you want to move beyond tutorial examples, and speed becomes a
factor, you can take a look at probstat, which is a python extension
module that does combinations and permutations in C.
http://probstat.sourceforge.net/
import probstat
li = [1,2,3,4]
li2 = ['Peter', 'Paul', 'Mary', 'Bill']
for (item) in probstat.Permutation(li):
print item
for (item) in probstat.Combination(li2, 2):
print item
Cheers,
John Hunter
More information about the Python-list
mailing list