Created
March 4, 2018 11:12
-
-
Save xiazhibin/fe925e8bba637960df2ada5ac1f6c038 to your computer and use it in GitHub Desktop.
full_permutation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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