Created
January 25, 2017 20:49
-
-
Save xiaq/99c58009dce1f8cbf4a3c096d44d192f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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