An anagram generator written in python that can be executed from the command line or used in projects as needed.
To find an anagram of a given word, we first sort the letters of the given word.
word = "peek"
sorted_word = ''.join(sorted(word))
sorted_word #sorted_word = "eekp"
Using a txt dictionary file, setup.py creates a python dictionary that uses a sorted_word
as a key, with its values being an array of all words that have that same sorted_word
.
anagram_dictionary = {}
#some code (see setup.py)
anagram_dictionary[sorted_word] #["keep","peek","peke"]
This allows us to find all anagrams of a given word by simply accessing anagram_dictionary[sorted_word]
for any word.
$ python anagram_generator.py <word>
See License for the license rights and limitations (MIT).