Re: Generator for k-permutations without repetition

2007-07-04 Thread Nis Jørgensen
bullockbefriending bard skrev: > On Jul 4, 7:09 pm, Nis Jørgensen <[EMAIL PROTECTED]> wrote: >> bullockbefriending bard skrev: >> A quick solution, not extensively tested >> >> # base needs to be an of the python builtin set >> >> def k_perm(base,k): >> for e in base: >>

Re: Generator for k-permutations without repetition

2007-07-04 Thread bullockbefriending bard
On Jul 4, 7:09 pm, Nis Jørgensen <[EMAIL PROTECTED]> wrote: > bullockbefriending bard skrev: > > > > > I was able to google a recipe for a k_permutations generator, such > > that i can write: > > > x = range(1, 4) # (say) > > [combi for combi in k_permutations(x, 3)] => > > > [[1, 1, 1], [1, 1, 2

Re: Generator for k-permutations without repetition

2007-07-04 Thread Nis Jørgensen
bullockbefriending bard skrev: > I was able to google a recipe for a k_permutations generator, such > that i can write: > > x = range(1, 4) # (say) > [combi for combi in k_permutations(x, 3)] => > > [[1, 1, 1], [1, 1, 2], [1, 1, 3], [1, 2, 1], [1, 2, 2], [1, 2, 3], [1, > 3, 1], [1, 3, 2], [1, 3

Re: Generator for k-permutations without repetition

2007-07-04 Thread Gerard Flanagan
On Jul 4, 1:22 pm, bullockbefriending bard <[EMAIL PROTECTED]> wrote: > I was able to google a recipe for a k_permutations generator, such > that i can write: > > x = range(1, 4) # (say) > [combi for combi in k_permutations(x, 3)] => > > [[1, 1, 1], [1, 1, 2], [1, 1, 3], [1, 2, 1], [1, 2, 2], [1,

Generator for k-permutations without repetition

2007-07-04 Thread bullockbefriending bard
I was able to google a recipe for a k_permutations generator, such that i can write: x = range(1, 4) # (say) [combi for combi in k_permutations(x, 3)] => [[1, 1, 1], [1, 1, 2], [1, 1, 3], [1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 3, 1], [1, 3, 2], [1, 3, 3], [2, 1, 1], [2, 1, 2], [2, 1, 3], [2, 2, 1