Revision: 17421
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 4, 2009 07:54 by purefusion
Initial Code
def swap(string, first, second, begin, end):
string[begin] = second
string[end] = first
def permutate(string, begin = 0):
end = len(string) -1
srange = end - begin
if srange == 1:
print string
else:
for i in range(0, srange):
swap(string, string[begin], string[begin+i], begin, begin+i)
permutate(string, begin+1)
swap(string, string[begin], string[begin+i], begin, begin+i)
Initial URL
Initial Description
Initial Title
Python Pre 2.6 Permutation
Initial Tags
Initial Language
Python