Jump to content

Jumble Solver


miawade

Recommended Posts

Hi.

I need help starting this assignment. The teacher/class is way over my head and I HAVE to do well on this assignment to pass...

So if anyone could assist me in doing and understanding this assignment, it would be greatly appreciated.

Thank you!


____________________________________________________________________________



We will write a program to solve word jumbles. You have probably seen them in the newspaper every day. Quick - what word is formed from the letters 'mezia'? 'cidde'? 'hucnah'? 'bouste'? Your program will solve these by brute force. It will have a list of English words (from Program 8, Spell Checker), and it will generate all permutations of the letters in the jumble. When it finds a permutation that is in the word list, its done.
daily jumble answer
Requirements

First, use your WordListIndexed to store the English language dictionary from the Spell Checker program. Our jumbles won't contain any punctuation marks or abbreviations. Don't store them in your WordListIndexed.

The primary class in this assignment, StringPermutationIterator, generates all the permutations of the letters in a given string. This class must have an iterator interface: next( ) and hasNext( ) (no remove( ) member function). There are two major challenges for this class. First, generate the permutations recursively. For example, to generate the permutations of a four letter string, put one of the four letters as the first letter and combine it will all permutations of the remaining 3 letters. Repeat until each letter has been used at the front (see example). For simplicity, you may assume that all the letters in the input string are unique (no duplications). If this assumption does not hold then we simply generate some duplicates that cause your program to run a little slower. We still get the correct result. Second, you must generate the permutations incrementally. It is not allowed to generate all permutations, store them in a list, and have the iterator walk down the list. Nor is it allowed to utilize the fact that there will be exactly n! permutations. You must create a true dynamic iterator that generates one at a time the elements of the set of permutations. See the general plan for dynamic iterators*.

Primary classes: StringPermutationIterator.
Application: Write a short main method that unscrambles the 4 jumbles from the first paragraph of this assignment plus 'ueassrkpc'.

____________________________________________________________________________

See example:

SPI("cats")
'c' + an of SPI("ats"). When SPI("ats") rolls over (false == hasNext()), create
an new nested SPI object
'a' + an object SPI("cts"). When SPI("cts") rolls over, create a new SPI object
't' + an object SPI("cas") create SPI("cat")
's' + an object SPI("cat") When SPI("cat") rolls over, we are done.
SPI("cats").hasNext() == false




*
General plan for dynamic iterators:

public class DynamicIterator<String>
implements Iterator<String> {

String buffer;

boolean hasNext() { return buffer != null; }

String next() {
String result = buffer;
buffer = createNextElement();
return result;
}
}

Edited by miawade
spell missing
Link to comment
Share on other sites

When using certain apps, specifically the stock email app and Metal for FB, sombols such as ', / " $ when used will swap out numbers or letters or jumble full words. Examples $30 will turn into $$0 after the 0 is added. Typing don't will change to don'' once the t is typed. Ive cleared and reset my keyboard settings, I don't use predictive text or autocorrect.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...