Skip to content

Instantly share code, notes, and snippets.

@patricklucas
Created January 30, 2012 16:42
Show Gist options
  • Save patricklucas/1705351 to your computer and use it in GitHub Desktop.
Save patricklucas/1705351 to your computer and use it in GitHub Desktop.
import sys
def perms(s):
num_perms = 2**len(s)
for perm in xrange(num_perms):
yield ''.join(
c.swapcase() if (1 << i & perm) else c
for i, c in enumerate(s)
)
for perm in perms(sys.argv[1]):
print perm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment