Created
December 16, 2012 07:48
-
-
Save anonymous/4304103 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
import re | |
from itertools import * | |
string = raw_input() | |
def isAlphaPart(string): | |
return re.match("[a-zA-Z]+",string) | |
parts = re.split('([^a-zA-Z]+)', string) | |
alpha_parts = [part for part in parts if isAlphaPart(part)] | |
parts_permutations = [list(permutations(part)) for part in alpha_parts] | |
products = apply(product, parts_permutations) | |
for result in products: | |
printme = "" | |
index = 0 | |
for part in parts: | |
if isAlphaPart(part): | |
printme += ''.join(result[index]) | |
index += 1 | |
else: | |
printme += part | |
print printme |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment