python math permutations code example
Example 1: permutations python
import itertools
print(list(itertools.permutations([1,2,3])))
Example 2: python combinations function
def combinations(iterable, r):
pool = tuple(iterable)
n = len(pool)
for indices in permutations(range(n), r):
if sorted(indices) == list(indices):
yield tuple(pool[i] for i in indices)
Example 3: python choose function
>>> from math import comb
>>> comb(20,10)