Skip to content

Instantly share code, notes, and snippets.

@docete
Created March 30, 2012 16:43
Show Gist options
  • Save docete/2252737 to your computer and use it in GitHub Desktop.
Save docete/2252737 to your computer and use it in GitHub Desktop.
def perm(s = [], beg = 0, end = 0):
if (len (s) == 0):
return;
if ( beg == end ):
print s
else:
for i in xrange(beg, end):
temp = s[i]
s[i] = s[beg]
s[beg] = temp
perm(s, beg+1, end)
temp = s[i]
s[i] = s[beg]
s[beg] = temp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment