Creating combination of sequences
Hung Jung Lu
hungjunglu at yahoo.com
Sun Nov 14 09:22:58 CET 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
and other previous threads and follow-ups. This question seems to pop
up more often than I thought.
More information about the Python-list