Permutations algoritm?

sismex01 at hebmex.com sismex01 at hebmex.com
Fri Nov 15 16:51:04 EST 2002


> From: William Park [mailto:opengeometry at yahoo.ca]
> Sent: Friday, November 15, 2002 3:42 PM
> 
> sismex01 at hebmex.com wrote:
> > Does anybody have a clear, simple, permutations algorithm
> > in Python?
> 
> Would you care to explain this?  Permutation can mean 
> different things.
> Concrete example might be good...
>

Of a set of different items 'S', obtain all distinct subsets of 'n'
items where all items in the subset are different.

So, if I have, for example:

   S = [ 0, 1, 2, 3 ]

the universe of available subsets of 3 items would be:

   s = [ (0, 1, 2),
         (0, 1, 3),
         (0, 2, 3),
         (1, 2, 3) ]

the universe of available subsets of 2 items would be:

   s = [ (0, 1),
         (0, 2),
         (0, 3),
         (1, 2),
         (1, 3),
         (2, 3) ]

Any help?

-gus




More information about the Python-list mailing list