This article mainly introduces the Python standard algorithm to achieve array full arrangement of the method, example analysis of the full arrangement of the principle and Python implementation techniques, the need for friends can refer to the
This article describes the Python standard algorithm to achieve an array of all methods, the code from foreign websites. Share to everyone for your reference. The specific analysis is as follows:
Take M (m≤n) elements from n different elements and arrange them in a certain order, called an arrangement of taking m elements from n different elements. All permutations are called when m=n.
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16-17 |
def Mideng (LI): if (Type (LI)!=list): Return if (Len (LI) ==1): Return [Li] result=[] to I in range (0,len (li[:)): bak=li[:] H Ead=bak.pop (i) #head of the recursive-produced value for J-Mideng (BAK): J.insert (0,head) Result.append (j) Return result def MM (n): if (type (n)!=int or n<2): Return return Mideng (list (1,n)) |
Call Method:
?
I hope this article will help you with your Python programming.