jweinst1
11/4/2015 - 10:28 PM

permutation functions iterative.

permutation functions iterative.

#permutation distinct element algorithm

#number of permutations:
import math
def perm_num(n):
    return math.factorial(n)//math.factorial(n-n)

#number of appearances in each slot  
def slot_events(k):
    return perm_num(k)//k
    
def permutations(lst):
    perm_template = []
    perms = []
    slot_max = slot_events(len(lst))
    slot_counts = {x:{y:0 for y in range(len(lst))} for x in lst}
    ####