Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 27 lines (22 sloc) 503 Bytes
#!/usr/bin/python
def perm(x,last=0):
if len(x)<=last+1:
yield x
else:
for t in perm(x,last+1):
yield t
for i in range(last+1,len(x)):
x[last],x[i]=x[i],x[last]
for t in perm(x,last+1):
yield t
x[last],x[i]=x[i],x[last]
def fact(n):
if n==0:
return(1)
else:
return n*fact(n-1)
print fact(6)
for t in perm([1,2,3,4,5,6]):
for i in range(len(t)):
print t[i],
print
You can’t perform that action at this time.