Creating combination of sequences
Hung Jung Lu
hungjunglu at yahoo.com
Sun Nov 14 03:22:58 EST 2004
minho_chae at yahoo.com (Minho Chae) wrote:
> I'm trying to create combinations of sequences.
> For example, if the sequence is 'acgt' and the length is 8,
> then I would like to have 4^8 results such as
> 'aaaaaaaa', 'aaaaaaac', 'aaaaaaag', 'aaaaaaat', ... 'tttttttt'
strings = lambda Xs, k: reduce(lambda r, i: [p + x for p in r for x
in Xs], range(k), [''])
print strings('acgt', 8)
This has been recently discussed. See
http://groups.google.com/groups?hl=en&lr=&selm=8ef9bea6.0410231916.450f67d%40posting.google.com
http://groups.google.com/groups?hl=en&lr=&selm=1gm5ojm.10239ef1m2hnrpN%25aleaxit%40yahoo.com
and other previous threads and follow-ups. This question seems to pop
up more often than I thought.
Kamsahapnida,
Hung Jung
More information about the Python-list
mailing list