Skip to content

Instantly share code, notes, and snippets.

@xiazhibin
Created March 4, 2018 11:12
Show Gist options
  • Save xiazhibin/fe925e8bba637960df2ada5ac1f6c038 to your computer and use it in GitHub Desktop.
Save xiazhibin/fe925e8bba637960df2ada5ac1f6c038 to your computer and use it in GitHub Desktop.
full_permutation
def full_permutation(arr, cursor):
if cursor == len(arr) - 1:
print arr
return
for i in range(cursor, len(arr)):
arr[cursor], arr[i] = arr[i], arr[cursor]
full_permutation(arr, cursor + 1)
arr[cursor], arr[i] = arr[i], arr[cursor]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment