Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding anagaram(s) of dictionary words

How can I take an input word (or sequence of letters) and output a word from a dictionary that contains exactly those letters?

Does java has an English dictionary class (list of words) that I can use, or are there open source implementations of this?

How can I optimize my code if this needs to be done repeatedly?

like image 679
Jony Avatar asked Apr 13 '10 09:04

Jony


1 Answers

Convert your dictionary into an anagram dictionary. In an anagram dictionary, the words are indexed by their letters in sorted alphabetical order. To look up anagrams for a certain word, you sort its letters and look up corresponding ones from the anagram dictionary.

like image 111
Matti Virkkunen Avatar answered Sep 20 '22 06:09

Matti Virkkunen