Skip to content

Instantly share code, notes, and snippets.

@mahendrakalkura
Last active August 29, 2015 14:10
Show Gist options
  • Save mahendrakalkura/ca3ed77b1ffbdc557b3a to your computer and use it in GitHub Desktop.
Save mahendrakalkura/ca3ed77b1ffbdc557b3a to your computer and use it in GitHub Desktop.
# -*- 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