4 ms·
> Permutations and combinations already exist within the itertools module. Not exactly. Given argument lists, Itertools provides result lists (actually, iterat
by lutusp 13y ago
> Permutations and combinations already exist within the itertools module.
Not exactly. Given argument lists, Itertools provides result lists (actually, iterators for that purpose) with the original elements permuted and combined, but doesn't provide numerical results for numerical arguments, as shown here: http://arachnoid.com/binomial_probability http://arachnoid.com/binomial_probability
I was referring to permutation and combination mathematical functions, not generator functions.
- megrimlock 13y agoPut differently, you want the functions that count the number of permutations and combinations possible, not functions that yield/generate the actual permutations and combinations.
- lutusp 13y agoYes, exactly, for a number of reasons including the problem of large arguments and results.
- blt 13y agoHmm. Python has default Bignum promotion so the naive N choose K implementation will not suffer from overflow. I guess it could be slow for large values, but how many casual users need to calculate N choose K for large N?