Last active
August 29, 2015 14:10
-
-
Save mahendrakalkura/ca3ed77b1ffbdc557b3a 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
# -*- coding: utf-8 -*- | |
from itertools import permutations | |
words = [ | |
'abel', | |
'able', | |
'appel', | |
'apple', | |
'bale', | |
'beal', | |
'heros', | |
'horse', | |
'shore', | |
'wrought', | |
'yuan', | |
'ziff', | |
'zillion', | |
] | |
def anagram(word): | |
print word | |
for word in set([ | |
''.join(w) for w in permutations(word, len(word)) | |
]): | |
if word in words: | |
print ' ', word | |
anagram('able') | |
anagram('apple') | |
anagram('fifz') | |
anagram('horse') | |
anagram('nauy') | |
anagram('noilliz') | |
anagram('roughtw') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment