Generating all possible combination of elements in a list

mensanator at aol.com mensanator at aol.com
Mon Jul 24 15:18:46 EDT 2006


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 += math.log(x, 10)
> >         return f
> >
> >     print logf(1060) - logf(1060 - 96)
> >
> > Of course there are other ways you can calculate it, e.g.
>
> My problem is not to calculate this number, but generate this much
> number of permutations in a  fastest possible ways.
>
> by the way,  logf(1060) - logf(1060 - 96) = 288.502297251. Do you mean
> there are only 289 possible permutation if 1060 elements taken 96 at a
> time. Wow it is cool.
>
> Please correct me if I got something wrong

Not 289, but 10**288.502297251.

That would make generating them all slightly intractable.




More information about the Python-list mailing list