PA #6: State Word Search

Introduction

As the crossword editor at the New York Times, Will Shortz is the world's most famous puzzle expert. On February 19th, 2012 he presented the following puzzle during the puzzle segment of NPR's Weekend Edition:

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.

The winner of this challenge was Roger Buch of Louisville Kentucky. Here is an excerpt from the transcript of the next week's show in which Mr. Buch describes his approach to solving the problem:

SHORTZ: Hey, Roger. Congratulations.

BUCH: Hello, Will. Thanks. Glad to finally talk with you.

MARTIN: So, Roger, you sent in the word omissions as your answer. How
did you figure it out?

BUCH: A lot of time staring at a globe with North America facing me.

MARTIN: Really?

BUCH: My globe has been sitting by my sofa for a week now. Any
commercial when I'm watching TV, looking over that globe, tracing my
finger around the country to come up with another word.

Mr. Buch is clearly not a computer scientist. No self-respecting computer scientist would solve this problem by hand when it would clearly be faster (and more fun) to write a program to solve it for us.

Your goal for this assignment is to write some recursive Java methods to support solving exactly the problem described above.

Provided Files

This problem can be broken into two parts:
  1. Representing states and their adjacency relationships.
  2. Searching for solutions.
We have provided helper code that addresses part 1). Your job is to handle part 2). The first step is to download the following files and make sure you understand how to use them:

Program Requirements

You must complete the unfinished methods in StateSpeller.java without changing the existing method signatures. You will need to add additional private methods to handle the recursive searches.

According to the instructions above, valid solutions may pick up any (non-zero) number of letters from each state. The code would be simpler if we only considered the first letter from each state name. Under that requirement "tam" would be a solution:

tam
[Tennessee, Arkansas, Missouri]
but "team" would not qualify. StateSpeller.java includes methods for both the original version of the problem and the single-letter variation. You should solve the single-letter version first. Once you have completed that version, the multi-letter version should be relatively straightforward.

Hints/Advice

The Longest Word

The methods in StateSpeller.java don't actually give us the longest possible word, they just allow us to check individual words to see if they can be spelled. Once those methods are finished, it should be straightforward to find the longest word through brute force: just check every word in the dictionary and keep track of the longest one that can be spelled. There is nothing to submit for this part of the assignment. Pride and glory will be yours if you can find a solution longer than Roger Buch's "omissions".

Extras

If you have extra time, there a number of possible extensions to this project:

Submitting/Grading

Submit StateSpeller.java through Autolab by the project deadline. Your grade will be based on the following factors.

Autograding based on correctness: 90%
Instructor grading based on style and readability: 10%

You submission will need to conform to the course style guidelines except for the requirement that a method must have fewer than three return statements.