public class StateSpeller
extends java.lang.Object
The word marten, as in the animal, consists of the beginning letters of Mississippi, Arkansas, Texas, and New Mexico. And you can actually drive from Mississippi to Arkansas to Texas to New Mexico, in that order. What is the longest common English word you can spell by taking the beginning letters of consecutive states in order, as you travel through them? My answer has eight letters. Maybe you can better mine. The longest answer will win.
Constructor and Description |
---|
StateSpeller(WordTree wordTree,
StateGraph stateGraph)
Construct a StateSpeller.
|
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<java.lang.String> |
anyWords(int minLength)
Return an ArrayList of solution strings where each string represents a
word that can be created by driving from one state to the next using the
beginning letters of each state name.
|
java.util.ArrayList<java.lang.String> |
firstLetterWords(int minLength)
Return an ArrayList of solution strings where each string represents a
word that can be created by driving from one state to the next using the
first letter of each state name.
|
public StateSpeller(WordTree wordTree, StateGraph stateGraph)
wordTree
- Initialized word tree.stateGraph
- Initialized state graph.public java.util.ArrayList<java.lang.String> firstLetterWords(int minLength)
word length [state1, state2, ... , stateN]Where word is an English word and length is the number of letters in that word. All solutions at least as long as minLength will be returned.
minLength
- The minimum solution lengthpublic java.util.ArrayList<java.lang.String> anyWords(int minLength)
word length [state1, state2, ... , stateN]Where word is an English word and length is the number of letters in that word. All solutions at least as long as minLength will be returned.
minLength
- The minimum solution length