I've made an anagram method to create all the possible combinations of a word, but I'd like to be able to check every letter combination.
For example: eastern would produce other variations such as earnest, but I'd also like it to produce variations such as east and eat and ate.
I already have a working dictionary checking whether the combinations are in the dictionary.
public void printAnagrams(String prefix, String word)
{
if(word.length() == 1) {
if (words.contains(prefix+word))
System.out.println(prefix + word);
}
else
{
for(int i = 0; i < word.length(); i++)
{
String current = word.substring(i, i + 1);
String before = word.substring(0, i);
String after = word.substring(i+1);
printAnagrams(prefix + current, before + after);
}
}
}