5. (Exhaustive Search, 8 points for functional correctness, 7 points for performance) An anagram puzzle is...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
5. (Exhaustive Search, 8 points for functional correctness, 7 points for performance) An anagram puzzle is a puzzle where the objective is to rearrange the letters of a word or phrase into another word or phrase, usually without reusing any words from the original. For example, the letters in the three words "locale plasma tedium" can be rearranged into three different words, "mallet palace sodium", as shown below: ma 1 dium XXXIII palace An anagram puzzle can be solved by exhaustive search. Complete the JavaScript function findThree WordAnagram in anagram.ja in your fork of the homework repository so that it takes a list of words in the original phrase and a list of words that may appear in the solution (defaulting to a dictionary of six-letter words from vocabulary.ja) and either returns undefined if there is no three-word anagram of the original phrase or else a sorted list of three new words that form an anagram. For example, the result of calling findThreeWordAnagram (['locale', 'plasma', 'tedium']) would be the list ['mallet', 'palace', 'sodium'] because those words appear in the default dictionary, do not include any of the input words, and form a three-word anagram of the input phrase. Unit tests to check functional correctness are provided in anagram. test.js, and you can run them using the test-once: anagram: small and test-once: anagram: large NPM scripts for small and large inputs, respectively. A nave exhaustive search will run very slowly on larger inputs. To earn the points for performance, find a way to reduce the search space so that the algorithm solves the puzzles in the unit tests within the generous 15-seconds-per-puzzle time limit. The unit tests associated with the test-once: anagram: large script have been configured to fail if this time limit is exceeded, so you can use them to check performance. Finally, use the project's built-in linter to check your code style. Any eslint-disable directives will be ignored by the autograder, so do not use them to hide warnings in your local copy, or you may miss code style problems that will cost you points. 1 MN my nung lo 2 3 4 5 6 7 8 9 10 55 } chars. sort(); 11 return chars.join(); 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 import { SIX_LETTER_VOCABULARY} function combineWordsAndSort Letters (words) { const chars = []; for (let i = 0; i < words.length; i++) { for (let j = 0; j < words [i].length; j++) { chars.push(words [i].charAt(j). to LowerCase()); 33 34 35 36 37 38 39 40 41 42 43 44 } } export function findThreeWordAnagram (words, vocabulary = SIX_LETTER_VOCABULARY) { const sorted = combineWordsAndSortLetters (words); } for (let i = 0; i < vocabulary.length; i++) { for (let j = i + 1; j < vocabulary.length; j++) { for (let k = j + 1; k < vocabulary.length; k++) { const others = [vocabulary[i], vocabulary [j], vocabulary [k]]; let found = false; for (let x = 0; x < words.length && found; x++) { for (let y = 0; y < others.length; y++) { if (words [x].toLowerCase() } from './vocabulary.js'; found = true; break; } png if (found) { continue; } // return undefined; === others [y].toLowerCase()) { if (sorted === combineWordsAndSortLetters (others)) { return others; > found 5. (Exhaustive Search, 8 points for functional correctness, 7 points for performance) An anagram puzzle is a puzzle where the objective is to rearrange the letters of a word or phrase into another word or phrase, usually without reusing any words from the original. For example, the letters in the three words "locale plasma tedium" can be rearranged into three different words, "mallet palace sodium", as shown below: ma 1 dium XXXIII palace An anagram puzzle can be solved by exhaustive search. Complete the JavaScript function findThree WordAnagram in anagram.ja in your fork of the homework repository so that it takes a list of words in the original phrase and a list of words that may appear in the solution (defaulting to a dictionary of six-letter words from vocabulary.ja) and either returns undefined if there is no three-word anagram of the original phrase or else a sorted list of three new words that form an anagram. For example, the result of calling findThreeWordAnagram (['locale', 'plasma', 'tedium']) would be the list ['mallet', 'palace', 'sodium'] because those words appear in the default dictionary, do not include any of the input words, and form a three-word anagram of the input phrase. Unit tests to check functional correctness are provided in anagram. test.js, and you can run them using the test-once: anagram: small and test-once: anagram: large NPM scripts for small and large inputs, respectively. A nave exhaustive search will run very slowly on larger inputs. To earn the points for performance, find a way to reduce the search space so that the algorithm solves the puzzles in the unit tests within the generous 15-seconds-per-puzzle time limit. The unit tests associated with the test-once: anagram: large script have been configured to fail if this time limit is exceeded, so you can use them to check performance. 5. (Exhaustive Search, 8 points for functional correctness, 7 points for performance) An anagram puzzle is a puzzle where the objective is to rearrange the letters of a word or phrase into another word or phrase, usually without reusing any words from the original. For example, the letters in the three words "locale plasma tedium" can be rearranged into three different words, "mallet palace sodium", as shown below: ma 1 dium XXXIII palace An anagram puzzle can be solved by exhaustive search. Complete the JavaScript function findThree WordAnagram in anagram.ja in your fork of the homework repository so that it takes a list of words in the original phrase and a list of words that may appear in the solution (defaulting to a dictionary of six-letter words from vocabulary.ja) and either returns undefined if there is no three-word anagram of the original phrase or else a sorted list of three new words that form an anagram. For example, the result of calling findThreeWordAnagram (['locale', 'plasma', 'tedium']) would be the list ['mallet', 'palace', 'sodium'] because those words appear in the default dictionary, do not include any of the input words, and form a three-word anagram of the input phrase. Unit tests to check functional correctness are provided in anagram. test.js, and you can run them using the test-once: anagram: small and test-once: anagram: large NPM scripts for small and large inputs, respectively. A nave exhaustive search will run very slowly on larger inputs. To earn the points for performance, find a way to reduce the search space so that the algorithm solves the puzzles in the unit tests within the generous 15-seconds-per-puzzle time limit. The unit tests associated with the test-once: anagram: large script have been configured to fail if this time limit is exceeded, so you can use them to check performance. 5. (Exhaustive Search, 8 points for functional correctness, 7 points for performance) An anagram puzzle is a puzzle where the objective is to rearrange the letters of a word or phrase into another word or phrase, usually without reusing any words from the original. For example, the letters in the three words "locale plasma tedium" can be rearranged into three different words, "mallet palace sodium", as shown below: ma 1 dium XXXIII palace An anagram puzzle can be solved by exhaustive search. Complete the JavaScript function findThree WordAnagram in anagram.ja in your fork of the homework repository so that it takes a list of words in the original phrase and a list of words that may appear in the solution (defaulting to a dictionary of six-letter words from vocabulary.ja) and either returns undefined if there is no three-word anagram of the original phrase or else a sorted list of three new words that form an anagram. For example, the result of calling findThreeWordAnagram (['locale', 'plasma', 'tedium']) would be the list ['mallet', 'palace', 'sodium'] because those words appear in the default dictionary, do not include any of the input words, and form a three-word anagram of the input phrase. Unit tests to check functional correctness are provided in anagram. test.js, and you can run them using the test-once: anagram: small and test-once: anagram: large NPM scripts for small and large inputs, respectively. A nave exhaustive search will run very slowly on larger inputs. To earn the points for performance, find a way to reduce the search space so that the algorithm solves the puzzles in the unit tests within the generous 15-seconds-per-puzzle time limit. The unit tests associated with the test-once: anagram: large script have been configured to fail if this time limit is exceeded, so you can use them to check performance. 5. (Exhaustive Search, 8 points for functional correctness, 7 points for performance) An anagram puzzle is a puzzle where the objective is to rearrange the letters of a word or phrase into another word or phrase, usually without reusing any words from the original. For example, the letters in the three words "locale plasma tedium" can be rearranged into three different words, "mallet palace sodium", as shown below: ma 1 dium XXXIII palace An anagram puzzle can be solved by exhaustive search. Complete the JavaScript function findThree WordAnagram in anagram.ja in your fork of the homework repository so that it takes a list of words in the original phrase and a list of words that may appear in the solution (defaulting to a dictionary of six-letter words from vocabulary.ja) and either returns undefined if there is no three-word anagram of the original phrase or else a sorted list of three new words that form an anagram. For example, the result of calling findThreeWordAnagram (['locale', 'plasma', 'tedium']) would be the list ['mallet', 'palace', 'sodium'] because those words appear in the default dictionary, do not include any of the input words, and form a three-word anagram of the input phrase. Unit tests to check functional correctness are provided in anagram. test.js, and you can run them using the test-once: anagram: small and test-once: anagram: large NPM scripts for small and large inputs, respectively. A nave exhaustive search will run very slowly on larger inputs. To earn the points for performance, find a way to reduce the search space so that the algorithm solves the puzzles in the unit tests within the generous 15-seconds-per-puzzle time limit. The unit tests associated with the test-once: anagram: large script have been configured to fail if this time limit is exceeded, so you can use them to check performance. 5. (Exhaustive Search, 8 points for functional correctness, 7 points for performance) An anagram puzzle is a puzzle where the objective is to rearrange the letters of a word or phrase into another word or phrase, usually without reusing any words from the original. For example, the letters in the three words "locale plasma tedium" can be rearranged into three different words, "mallet palace sodium", as shown below: ma 1 dium XXXIII palace An anagram puzzle can be solved by exhaustive search. Complete the JavaScript function findThree WordAnagram in anagram.ja in your fork of the homework repository so that it takes a list of words in the original phrase and a list of words that may appear in the solution (defaulting to a dictionary of six-letter words from vocabulary.ja) and either returns undefined if there is no three-word anagram of the original phrase or else a sorted list of three new words that form an anagram. For example, the result of calling findThreeWordAnagram (['locale', 'plasma', 'tedium']) would be the list ['mallet', 'palace', 'sodium'] because those words appear in the default dictionary, do not include any of the input words, and form a three-word anagram of the input phrase. Unit tests to check functional correctness are provided in anagram. test.js, and you can run them using the test-once: anagram: small and test-once: anagram: large NPM scripts for small and large inputs, respectively. A nave exhaustive search will run very slowly on larger inputs. To earn the points for performance, find a way to reduce the search space so that the algorithm solves the puzzles in the unit tests within the generous 15-seconds-per-puzzle time limit. The unit tests associated with the test-once: anagram: large script have been configured to fail if this time limit is exceeded, so you can use them to check performance. Finally, use the project's built-in linter to check your code style. Any eslint-disable directives will be ignored by the autograder, so do not use them to hide warnings in your local copy, or you may miss code style problems that will cost you points. Finally, use the project's built-in linter to check your code style. Any eslint-disable directives will be ignored by the autograder, so do not use them to hide warnings in your local copy, or you may miss code style problems that will cost you points. Finally, use the project's built-in linter to check your code style. Any eslint-disable directives will be ignored by the autograder, so do not use them to hide warnings in your local copy, or you may miss code style problems that will cost you points. Finally, use the project's built-in linter to check your code style. Any eslint-disable directives will be ignored by the autograder, so do not use them to hide warnings in your local copy, or you may miss code style problems that will cost you points. Finally, use the project's built-in linter to check your code style. Any eslint-disable directives will be ignored by the autograder, so do not use them to hide warnings in your local copy, or you may miss code style problems that will cost you points. 1 MN my nung lo 2 3 4 5 6 7 8 9 10 55 } chars. sort(); 11 return chars.join(); 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 import { SIX_LETTER_VOCABULARY} function combineWordsAndSort Letters (words) { const chars = []; for (let i = 0; i < words.length; i++) { for (let j = 0; j < words [i].length; j++) { chars.push(words [i].charAt(j). to LowerCase()); 33 34 35 36 37 38 39 40 41 42 43 44 } } export function findThreeWordAnagram (words, vocabulary = SIX_LETTER_VOCABULARY) { const sorted = combineWordsAndSortLetters (words); } for (let i = 0; i < vocabulary.length; i++) { for (let j = i + 1; j < vocabulary.length; j++) { for (let k = j + 1; k < vocabulary.length; k++) { const others = [vocabulary[i], vocabulary [j], vocabulary [k]]; let found = false; for (let x = 0; x < words.length && found; x++) { for (let y = 0; y < others.length; y++) { if (words [x].toLowerCase() } from './vocabulary.js'; found = true; break; } png if (found) { continue; } // return undefined; === others [y].toLowerCase()) { if (sorted === combineWordsAndSortLetters (others)) { return others; > found 1 MN my nung lo 2 3 4 5 6 7 8 9 10 55 } chars. sort(); 11 return chars.join(); 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 import { SIX_LETTER_VOCABULARY} function combineWordsAndSort Letters (words) { const chars = []; for (let i = 0; i < words.length; i++) { for (let j = 0; j < words [i].length; j++) { chars.push(words [i].charAt(j). to LowerCase()); 33 34 35 36 37 38 39 40 41 42 43 44 } } export function findThreeWordAnagram (words, vocabulary = SIX_LETTER_VOCABULARY) { const sorted = combineWordsAndSortLetters (words); } for (let i = 0; i < vocabulary.length; i++) { for (let j = i + 1; j < vocabulary.length; j++) { for (let k = j + 1; k < vocabulary.length; k++) { const others = [vocabulary[i], vocabulary [j], vocabulary [k]]; let found = false; for (let x = 0; x < words.length && found; x++) { for (let y = 0; y < others.length; y++) { if (words [x].toLowerCase() } from './vocabulary.js'; found = true; break; } png if (found) { continue; } // return undefined; === others [y].toLowerCase()) { if (sorted === combineWordsAndSortLetters (others)) { return others; > found 1 MN my nung lo 2 3 4 5 6 7 8 9 10 55 } chars. sort(); 11 return chars.join(); 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 import { SIX_LETTER_VOCABULARY} function combineWordsAndSort Letters (words) { const chars = []; for (let i = 0; i < words.length; i++) { for (let j = 0; j < words [i].length; j++) { chars.push(words [i].charAt(j). to LowerCase()); 33 34 35 36 37 38 39 40 41 42 43 44 } } export function findThreeWordAnagram (words, vocabulary = SIX_LETTER_VOCABULARY) { const sorted = combineWordsAndSortLetters (words); } for (let i = 0; i < vocabulary.length; i++) { for (let j = i + 1; j < vocabulary.length; j++) { for (let k = j + 1; k < vocabulary.length; k++) { const others = [vocabulary[i], vocabulary [j], vocabulary [k]]; let found = false; for (let x = 0; x < words.length && found; x++) { for (let y = 0; y < others.length; y++) { if (words [x].toLowerCase() } from './vocabulary.js'; found = true; break; } png if (found) { continue; } // return undefined; === others [y].toLowerCase()) { if (sorted === combineWordsAndSortLetters (others)) { return others; > found 1 MN my nung lo 2 3 4 5 6 7 8 9 10 55 } chars. sort(); 11 return chars.join(); 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 import { SIX_LETTER_VOCABULARY} function combineWordsAndSort Letters (words) { const chars = []; for (let i = 0; i < words.length; i++) { for (let j = 0; j < words [i].length; j++) { chars.push(words [i].charAt(j). to LowerCase()); 33 34 35 36 37 38 39 40 41 42 43 44 } } export function findThreeWordAnagram (words, vocabulary = SIX_LETTER_VOCABULARY) { const sorted = combineWordsAndSortLetters (words); } for (let i = 0; i < vocabulary.length; i++) { for (let j = i + 1; j < vocabulary.length; j++) { for (let k = j + 1; k < vocabulary.length; k++) { const others = [vocabulary[i], vocabulary [j], vocabulary [k]]; let found = false; for (let x = 0; x < words.length && found; x++) { for (let y = 0; y < others.length; y++) { if (words [x].toLowerCase() } from './vocabulary.js'; found = true; break; } png if (found) { continue; } // return undefined; === others [y].toLowerCase()) { if (sorted === combineWordsAndSortLetters (others)) { return others; > found 1 MN my nung lo 2 3 4 5 6 7 8 9 10 55 } chars. sort(); 11 return chars.join(); 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 import { SIX_LETTER_VOCABULARY} function combineWordsAndSort Letters (words) { const chars = []; for (let i = 0; i < words.length; i++) { for (let j = 0; j < words [i].length; j++) { chars.push(words [i].charAt(j). to LowerCase()); 33 34 35 36 37 38 39 40 41 42 43 44 } } export function findThreeWordAnagram (words, vocabulary = SIX_LETTER_VOCABULARY) { const sorted = combineWordsAndSortLetters (words); } for (let i = 0; i < vocabulary.length; i++) { for (let j = i + 1; j < vocabulary.length; j++) { for (let k = j + 1; k < vocabulary.length; k++) { const others = [vocabulary[i], vocabulary [j], vocabulary [k]]; let found = false; for (let x = 0; x < words.length && found; x++) { for (let y = 0; y < others.length; y++) { if (words [x].toLowerCase() } from './vocabulary.js'; found = true; break; } png if (found) { continue; } // return undefined; === others [y].toLowerCase()) { if (sorted === combineWordsAndSortLetters (others)) { return others; > found
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Hyten Corporation On June 5, 1998, a meeting was held at Hyten Corporation, between Bill Knapp, Director of Marketing/Sales, and John Rich, director of engineering. The purpose of the meeting was to...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
On April 30, the end of the first month of operations, Joplin Company prepared the following income statement, based on the absorption costing concept: Joplin Company Absorption Costing Income...
-
Crockett Security Systems' revenues for 2016 totaled $21.9 million. As with most companies, Crockett is a defendant in lawsuits related to its products. Note 14 of the Crockett annual report for 2016...
-
Sierra Stone Ltd. received an invoice dated January 16 with terms 2/15, n/30. The amount stated on the invoice was $2702.00. (a) What is the last day for taking the cash discount? (b) What is the...
-
What is the proof of service?
-
Use the data from Problem 19 to rebalance the line with a cycle time of 90 seconds. How does the number of workstations change? What happens to the output and the lines efficiency?
-
The liabilities of the Smith Company are $120,000 and its owner's equity is $232,000. What is the amount of the company's total assets? The total assets of the Jones Company are $190,000 and its...
-
At April 30, partners capital balances in YBG Company are: Younger $30,000, Beyer $16,000, and Giger $10,000. The income-sharing ratios are 5:3:2, respectively. On May 1, the YBGE Company is formed...
-
Suppose that in your first year of college you spend $20,100.00 more than you earn. In your second year, your expenses increase a bit, leading you to spend $20,600.00 more than you earn. This gap...
-
You are standing above the point (5, 1) on the surface z = 10 - (2x + y). (a) In which direction should you walk to descend fastest? (Give your answer as a unit 2-vector.) direction = (b) If you...
-
Provide a 4 Ps Analysis,Service Marketing and Internal Marketing about Superfly (a fishing equipment company) cooperation With Outdoor Sports Organizations. Price range: What is the price of the...
-
Discuss the evolution of the bildungsroman genre from its roots in 18th-century literature to its modern manifestations. What thematic elements and narrative techniques characterize this genre, and...
-
How does the structure of the epistolary novel, as seen in works like "Dracula" by Bram Stoker or "The Color Purple" by Alice Walker, facilitate complex character development and narrative tension ?
-
Chip Company produces three products, Kin, Ike, and Bix. Each product uses the same direct material. Kin uses 3.1 pounds of the material, Ike uses 3.7 pounds of the material, and Bix uses 6.3 pounds...
-
A customer is traveling to a branch office, and the network administrator provides her with a static IP address for her laptop. Which should the customer do to use the static IP address? Run the...
-
What types of questions can be answered by analyzing financial statements?
-
How much of each of the following prizes or awards is taxable? a. Cheline received a $50,000 gift bag at the Oscars in 2012. b. Jon received a gold watch worth $350 for 25 years of service to his...
-
Ken paid the following amounts for interest during 2012: Qualified interest on home mortgage...........................................$4,700 Auto loan...
-
How are qualified dividends taxed in 2012? Please give the two rates of tax which apply to qualified dividends, and specify when each of these rates applies._________________________...
-
Using the Wilson method with \(\theta=1.4\), solve Problem 11.18. Data From Problem 11.18:- Using the central difference method, find the response of the two-degree-of-freedom system shown in Fig....
-
Using the Wilson method with \(\theta=1.4\), solve Problem 11.20. Data From Problem 11.20:- The equations of motion of a two-degree-of-freedom system are given by \(2 \ddot{x}_{1}+6 x_{1}-2 x_{2}=5\)...
-
Using the Newmark method with \(\alpha=\frac{1}{6}\) and \(\beta=\frac{1}{2}\), solve Problem 11.18. Data From Problem 11.18:- Using the central difference method, find the response of the...
Study smarter with the SolutionInn App