Created
May 6, 2013 07:03
-
-
Save abarax/5523738 to your computer and use it in GitHub Desktop.
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 perms(arr): | |
if len(arr) == 1: | |
return [arr] | |
ret = [] | |
head = arr[:1] | |
for tail in perms(arr[1:]): | |
for i in range(len(arr)): | |
ret.append(tail[i:] + head + tail[:i]) | |
return ret | |
print perms([1,2,3,4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment