2018-12-11 15:57:58 +08:00
|
|
|
''' mbinary
|
|
|
|
#########################################################################
|
|
|
|
# File : permute_back_track.py
|
|
|
|
# Author: mbinary
|
|
|
|
# Mail: zhuheqin1@gmail.com
|
2019-01-31 12:09:46 +08:00
|
|
|
# Blog: https://mbinary.xyz
|
2018-12-11 15:57:58 +08:00
|
|
|
# Github: https://github.com/mbinary
|
|
|
|
# Created Time: 2018-11-25 12:32
|
|
|
|
# Description:
|
|
|
|
#########################################################################
|
|
|
|
'''
|
2018-12-11 15:28:05 +08:00
|
|
|
def permute(n):
|
|
|
|
def _util(lst,i):
|
|
|
|
if i==n:print(lst)
|
|
|
|
else:
|
|
|
|
for j in range(i,n):
|
|
|
|
lst[i],lst[j]=lst[j],lst[i]
|
|
|
|
_util(lst,i+1)
|
|
|
|
lst[i],lst[j]=lst[j],lst[i]
|
|
|
|
_util([i for i in range(n)],0)
|
|
|
|
|
|
|
|
if __name__=='__main__':
|
|
|
|
permute(5)
|