subset permutations

Rick Wotnaz desparn at wtf.com
Thu Dec 8 22:40:56 EST 2005


Jay Parlar <jparlar at cogeco.ca> wrote in 
news:mailman.1878.1134095737.18701.python-list at python.org:

> http://www.bigbold.com/snippets/posts/show/753

A string is also iterable, so whether s is the string (as shown) or 
list('ACDEFGHIKLMNPQRSTVWY'), as you have it above, this should 
generate the 160000 permutations, as a list of 4-character strings.

s = 'ACDEFGHIKLMNPQRSTVWY'
x = ['%s%s%s%s' % (v,w,x,y) for v in s 
    	for w in s for x in s for y in s]


-- 
rzed



More information about the Python-list mailing list