Re: Generating all possible combination of elements in a list

2006-07-25 Thread Mir Nazim
> Again, I don't understand. You have 924 things, eliminate some of them, > and end up with 1060 things? Eliminating elements should decrease > the number, not increase it. yes, u are right I had to types of lists: one one them has 924 permutations and other has 792 making them 1722. out of which

Re: Generating all possible combination of elements in a list

2006-07-25 Thread Mir Nazim
> Again, I don't understand. You have 924 things, eliminate some of them, > and end up with 1060 things? Eliminating elements should decrease > the number, not increase it. yes, u are right I had to types of lists: one one them has 924 permutations and other has 792 making them 1722. out of which

Re: Generating all possible combination of elements in a list

2006-07-25 Thread Martin v. Löwis
Mir Nazim wrote: > condition are there cannot be more than 3 consecutive 2's or 1's > >> If the task is to produce all distinct permutations of 6 occurrences >> of 1 and 6 occurrences of 2, I suggest the program below. It needs >> produces much fewer than 12! results (namely, 924). >> > > Yes tha

Re: Generating all possible combination of elements in a list

2006-07-24 Thread [EMAIL PROTECTED]
Mir Nazim wrote: > Paul Rubin wrote: > > > 1060! / (1060 - 96)! > > > > > More than you want to think about: > > > > import math > > > > def logf(n): > > """return base-10 logarithm of (n factorial)""" > > f = 0.0 > > for x in xrange(1,n+1): > > f += mat

Re: Generating all possible combination of elements in a list

2006-07-24 Thread Mir Nazim
Paul Rubin wrote: > > 1060! / (1060 - 96)! > > More than you want to think about: > > import math > > def logf(n): > """return base-10 logarithm of (n factorial)""" > f = 0.0 > for x in xrange(1,n+1): > f += math.log(x, 10) > return f > > pr

Re: Generating all possible combination of elements in a list

2006-07-24 Thread Paul Rubin
"Mir Nazim" <[EMAIL PROTECTED]> writes: > Now I ahave a lits with 1060 lists in it. Now comes the hard part. > How many possible distinct ways are there to arrange 1060 elements > taken 96 at a time > > 1060! / (1060 - 96)! More than you want to think about: import math def logf(n):

Re: Generating all possible combination of elements in a list

2006-07-24 Thread Mir Nazim
Martin v. Löwis wrote: > Mir Nazim wrote: > > Example Problem: > > > > Generate all possible permutations for > > [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2] > > > > [1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2] (notice an extra 2 ) > > > > eliminate some combinations based on some conditions and combine the > >

Re: Generating all possible combination of elements in a list

2006-07-23 Thread Martin v. Löwis
Mir Nazim wrote: > Example Problem: > > Generate all possible permutations for > [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2] > > [1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2] (notice an extra 2 ) > > eliminate some combinations based on some conditions and combine the > rest of combinations. And now generate al

Generating all possible combination of elements in a list

2006-07-23 Thread Mir Nazim
Hello, I need to write scripts in which I need to generate all posible unique combinations of an integer list. Lists are a minimum 12 elements in size with very large number of possible combination(12!) I hacked a few lines of code and tried a few things from Python CookBook (http://aspn.activest