Generating all possible combination of elements in a list
Mir Nazim
mirnazim at gmail.com
Mon Jul 24 13:51:12 EDT 2006
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
More information about the Python-list
mailing list