Objectives 1. To learn how to use recursion in programming 2. To learn how to im
ID: 3652051 • Letter: O
Question
Objectives1. To learn how to use recursion in programming
2. To learn how to implement known algorithms
3. To learn how to use dynamic memory allocation
Problem: Jumble Puzzle Solver (jumble.c)
Jumble is a world game in which players are given a scrambled set of letters. Players then try to make the most valid words from those letters.
For example, given the letters TCA the user could form the words CAT, and ACT.
Our program will solve jumble puzzles for players. First, the program must read in a dictionary of valid words. This file will contain English words in alphabetical order.
Then, the program must ask the user if they have a jumble puzzle to solve. If so, prompt the user for a jumbled word. Use the recursive permutation algorithm to create all permutations of the jumbled letters and then use a binary search to search for each permutation in the dictionary.
The program should output all permutations of the jumbled word that appear in the dictionary. If no permutations form a valid word, simply display a message to that effect.
When this process is completed the user should be allowed to enter additional words.
Specifications
These specifications must be followed exactly.
Input: User
1. The user will enter y or Y to indicate they have another puzzle to solve
2. The user will enter n or N to indicate they do not have any more puzzles to solve
3. The user will enter their jumbled letters in UPPERCASE
4. The maximum number of letters for a jumble puzzle is 19 letters
Input: File
1. The first line of the input file will be an integer n, that indicates how many words are in the dictionary
a. You must use a 2D array to store the dictionary
b. You must use dynamic memory allocation to set the size of the dictionary array
c. The maximum number of letters for a word in the dictionary is 19 letters
2. The following n lines will each contain one valid word for the dictionary
a. The dictionary words will be in UPPERCASE
b. The words will be in alphabetical order
Output:
1. You must output to two different locations
a. The screen
b. An output file called
Explanation / Answer
#include #include #include #include using namspace std; int main() { enum fields{WORD, HINT, NUM_FIELDS}; const int NUM_WORDS = 5; const string WORDS[NUM_WORDS][NUM_FIELDS] = { {"wall", "Do you feel you're banging agianst something?"}, {"glasses", "These might help you see the answer."}, {"labored", "Going slowly, is it?"}, {"persistent", "Keep at it."}, {"jumble", "It's what the game is all about."} }; srand(time(0)); int choice = (rand()% NUM_WORDS); string theWord = WORDS[choice][WORD]; //word to guess string theHint = WORDS[choice][HINT]; //hint for word string jumble = theWord; //jumbled version of word int length = jumble.size(); for (int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.