Home > Backend Development > Python Tutorial > pytyon 带有重复的全排列

pytyon 带有重复的全排列

WBOY
Release: 2016-06-06 11:27:47
Original
1655 people have browsed it

代码如下:


from sys import argv
script, start, end = argv
vis = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
ans = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
def dfs(cur, m):
 ans[cur] = m
 if cur == int(end) - int(start) + 1:
  for i in xrange(int(start), int(end) + 1):
   print ans[i],
  return
 cur = cur + 1
 for i in xrange(int(start), int(end) + 1):
  dfs(cur, i)
  print
dfs(0, start) 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template