-
-
Save cammckinnon/4304128 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() | |
parts = re.split('([^a-zA-Z]+)', string) | |
alpha_parts = [part for part in parts if re.match("[a-zA-Z]+",part)] | |
perms = permutations(apply(chain,alpha_parts)) | |
for result in set(perms): | |
printme = "" | |
index = 0 | |
for char in string: | |
if re.match("[a-zA-Z]",char): | |
printme += result[index] | |
index += 1 | |
else: | |
printme += char | |
print printme |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment