Permutation over a list with selected elements

weidongtom at gmail.com weidongtom at gmail.com
Tue Jun 19 03:27:05 EDT 2007


Hi,

I have been working at this problem, and I think I need a permutation
algorithm that does
the following:

Given a list of elements that are either a character or a character
follows by a number, e.g.

['a', 'b', 'c1', 'd', 'e1', 'f', 'c2', 'x', 'e2']

find all the permutations that are given by switching the positions of
the elements that:
 (1) begins with the same letter, and
 (2) follows by a number.

With the above list, some possible permutations are:

['a', 'b', 'c2', 'd', 'e1', 'f', 'c1', 'x', 'e2']
['a', 'b', 'c1', 'd', 'e2', 'f', 'c2', 'x', 'e1']
['a', 'b', 'c2', 'd', 'e2', 'f', 'c1', 'x', 'e1']

Can anyone help me out? Thanks in advance.




More information about the Python-list mailing list