The method of implementing array full arrangement by Python standard algorithm

Source: Internet
Author: User

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:

?
1 MM (6)

I hope this article will help you with your Python programming.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.