Skip to content

Instantly share code, notes, and snippets.

@xiaq
Created January 25, 2017 20:49
Show Gist options
  • Select an option

  • Save xiaq/99c58009dce1f8cbf4a3c096d44d192f to your computer and use it in GitHub Desktop.

Select an option

Save xiaq/99c58009dce1f8cbf4a3c096d44d192f to your computer and use it in GitHub Desktop.
def perm(a, i):
if i == len(a):
print(a)
return
for j in range(i, len(a)):
a[i], a[j] = a[j], a[i]
perm(a, i+1)
a[i], a[j] = a[j], a[i]
if __name__ == '__main__':
perm(range(4), 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment