Created
November 3, 2010 12:37
-
-
Save dagoof/661030 to your computer and use it in GitHub Desktop.
alternative to http://users.softlab.ntua.gr/~ttsiod/yield.html
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 permute(queue, final = []): | |
for item in queue: | |
remaining_queue, pending = [e for e in queue if e is not item], final + [item] | |
if remaining_queue: | |
for more in permute(remaining_queue, pending): | |
yield more | |
else: | |
yield pending |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment