It’s well known that there are so many formulae in the field of permutation and combination, as described on the following websites:

I want to know if there are convenient methods for me to validate/derive/deduce them with python.

Regards,

HY

It’s well known that there are so many formulae in the field of permutation and combination, as described on the following websites:

I want to know if there are convenient methods for me to validate/derive/deduce them with python.

Regards,

HY

Hi Hongyi,

for finite stuff you might use itertools.permutations alike this:

```
from itertools import permutations
from sympy import symbols
from sympy import simplify
from operator import add, mul
a,b,c = symbols("a,b,c")
term1 = reduce(mul, reduce(add, (permutations([a,b,c]))))
term2 = reduce(mul, reduce(add, (permutations([c,b,a]))))
simplify(term1 - term2) == 0
```

which returns True.

Cheers, Dominik

The following line should be added to the package/module import part for your above example:

`from functools import reduce`

Seems to be one of those ridiculously unnecessary incompatibilities between Python 2.7 and Python 3 - in Python 2.7 “reduce” is a built-in: