SoFunction
Updated on 2024-10-29

python standard algorithm for full array alignment

This article example describes the python standard algorithm to realize the array full alignment method, the code is from a foreign website. Shared for your reference. Specific analysis is as follows:

Taking any m (m ≤ n) elements from n different elements and arranging them in a certain order is called a permutation of m elements from n different elements. When m=n all permutations are called full permutations.

def Mideng(li):
  if(type(li)!=list):
    return
  if(len(li)==1):
    return [li]
  result=[]
  for i in range(0,len(li[:])):
    bak=li[:]
    head=(i) #head of the recursive-produced value
    for j in Mideng(bak):
      (0,head)
      (j)
  return result
def MM(n):
  if(type(n)!=int or n<2):
    return
  return Mideng(list(range(1,n)))

Call method:

MM(6)

I hope that what I have described in this article will help you in your Python programming.