LetterInventory
work?
LetterInventory
is a very useful structure that keeps track of how many of each letter a given String
has (ignoring whitespace, capitalization, and non-alphabetic characters). Each LetterInventory
object has many methods for retrieving or modifying its properties. They include:
LetterInventory
have any letters in it? (isEmpty
)LetterInventory
have? (size
)LetterInventory
, in alphabetical order? (toString
)add
)subtract
)print
to print no more than a certain number of words?
max
words.
print
keep looking for anagrams once it exceeds max
?
LetterInventory
?
[love, lace]
would not be an appropriate anagram for the string Ada Lovelace
because it doesn't use the letters ada
.
dict1.txt
as your dictionary since it's small enough to check which of the words can be made from a given phrase just by looking at it. Once you've convinced yourself that your program works with this small dictionary, you should move on to the larger ones. The Output Comparison Tool on the Homework page of the course website shows output for various phrases from various dictionaries. Make sure to take advantage of this valuable resource! Remember that the tests from the comparison tool are not exhaustive, but it's a good place to start.
System.out.println
to find out what the anagram looks like at certain points in your program. Try before and after your recursive step as well as in your base case. You might also find the debugger in jGRASP useful.