subset permutations

Ben Finney bignose+hates-spam at benfinney.id.au
Fri Dec 9 00:03:46 EST 2005


Jay Parlar <jparlar at cogeco.ca> wrote:
> For instance, say you have the list ['A','B',C','D'], and you want
> all  possible TWO letter permutations.

    $ dict permutation
    From The Collaborative International Dictionary of English v.0.48 [gcide]:

      Permutation \Per`mu*ta"tion\ (p[~e]r`m[-u]"t[=a]"sn[u^]n), n.
    [...]
         2. (Math.)
            (a) The arrangement of any determinate number of things,
                as units, objects, letters, etc., in all possible
                orders, one after the other; -- called also
                {alternation}. Cf. {Combination}, n., 4.

> Do you want the result to be:
> AB, AC, AD, BC, BD, CD

That is the complete set of combinations of the letters.

> Or, do you want AB,BA,AC,CA,AD,DA,BC,CB,BD,DB,CD,DB ?

That is the complete set of permutations of the letters.

-- 
 \       "I don't know anything about music. In my line you don't have |
  `\                          to."  -- Elvis Aaron Presley (1935-1977) |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list