Re: Question about permutations (itertools)

2010-05-31 Thread Ulrich Eckhardt
Vincent Davis wrote: > I am looking for the most efficient (speed) way to produce an an > iterator to of permutations. > One of the problem I am having it that neither combinations nor > permutations does not exactly what I want directly. > For example If I want all possible ordered lists of 0,1 of

Re: Question about permutations (itertools)

2010-05-31 Thread Mark Dickinson
On May 31, 3:04 pm, Vincent Davis wrote: > For example If I want all possible ordered lists of 0,1 of length 3 > (0,0,0) > (0,0,1) > (0,1,1) > (1,1,1) > (1,0,1) > (1,1,0) > (1,0,0) > I don't see a way to get this directly from the itertools. But maybe I > am missing something. In this case, you'r

Re: Question about permutations (itertools)

2010-05-31 Thread Vincent Davis
On Mon, May 31, 2010 at 8:17 AM, Xavier Ho wrote: > >> >>> list(combinations_with_replacement('01',3)) >> ('0', '0', '0') >> ('0', '0', '1') >> ('0', '1', '1') >> ('1', '1', '1') >> >> Is it possible to get combinations_with_replacement to return numbers >> rather than strings? (see above) >

Re: Question about permutations (itertools)

2010-05-31 Thread Peter Otten
Vincent Davis wrote: > As a note I am doing this in py3. > > I am looking for the most efficient (speed) way to produce an an > iterator to of permutations. > One of the problem I am having it that neither combinations nor > permutations does not exactly what I want directly. > For example If I w

Re: Question about permutations (itertools)

2010-05-31 Thread Xavier Ho
> >>> list(combinations_with_replacement('01',3)) > ('0', '0', '0') > ('0', '0', '1') > ('0', '1', '1') > ('1', '1', '1') > > Is it possible to get combinations_with_replacement to return numbers > rather than strings? (see above) > >>> list(combinations_with_replacement(range(0,2), 3)) [(0, 0, 0)

Question about permutations (itertools)

2010-05-31 Thread Vincent Davis
As a note I am doing this in py3. I am looking for the most efficient (speed) way to produce an an iterator to of permutations. One of the problem I am having it that neither combinations nor permutations does not exactly what I want directly. For example If I want all possible ordered lists of 0,