[Python] permutation

[code lang=”python”]
#!/usr/bin/python
def perm(a,b=[]):
if not len(a):
print ”.join(b)
for i in range(len(a)):
b.append(a.pop(i))
perm(a,b)
a.insert(i,b.pop())
perm(list("abcd"))
[/code]

abcd
abdc
acbd
acdb
adbc
adcb
bacd
badc
bcad
bcda
bdac
bdca
cabd
cadb
cbad
cbda
cdab
cdba
dabc
dacb
dbac
dbca
dcab
dcba

[Python]image crawler for deviant art