Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

? Spelling Bee The New York Times regularly publishes a wordplay puzzle called the Spelling Bee. Each puzzle consists of seven distinct letters, one of

? Spelling Bee The New York Times regularly publishes a wordplay puzzle called the "Spelling Bee. Each puzzle consists of seven distinct letters, one of which is the "key" letter. The goal is to come up with as many words as possible that obey the following rules: • All words are valid English words. The words are at least 5 letters long. (The online version, shown below, only requires words that are at least 4 letters long.) • The words contain the key letter. • The words do not contain any letters outside the seven letters. • Letters may be reused, including the key letter. rHelp Save & Quit Yesterday's Answers Amazing . . . . . 4 You have found 22 words Accuracy Arch Curry Hard Array Hardy Aura ???? Hurray Card Carry Hurry Ruddy Char Yard Chard Chary Church Crud Delete O Enter Cruddy Curd Curdy rRequirements Implement a function spelling Beesolutions (wordlist, puzzles) that follows the function signature below: Input: wordlist: An array of strings. This is your list of "valid English words". • puzzles: An array of strings. Each string is a puzzle. Output: An array of integers. Each integer should be the number of valid words in the corresponding puzzle. Constraints: • Both the wordlist and the puzzles will be supplied in all capital letters. • All words in the wordlist will be of length 5 or greater. (In other words, you don't have to worry about the word length constraint of the puzzle.) • Every puzzle will be of exactly length 7. • Every puzzle will consist of 7 distinct letters. Performance of your solution is important! A naive solution will not get you full points - to score 100/100, you'll need something significantly faster. Example Input: wordlist: ['APPLE', PLEAS', 'PLEASE"] puzzles: ['AELWXYZ', 'AELPXYZ', 'AELPSXY', 'SAELPXY', 'XAELPSY'] rExample Input: wordlist: ['APPLE', 'PLEAS', 'PLEASE] puzzles: ['AELWXYZ', 'AELPXYZ', 'AELPSXY', 'SAELPXY', 'XAELPSY'] Expected output: [0, 1, 3, 2, 0] Explanation: • None of the words in the wordlist can be formed from the letters in puzzle 0. • Only APPLE is valid for puzzle 1. • All three words are valid for puzzle 2. • Only PLEAS and PLEASE are valid for puzzle 3, since APPLE does not contain the key letter S. • None of the words are valid for puzzle 4, since none contain the key letter X. rFor our purposes, we'll express each problem as a string of length 7, where the first letter (the one at position 0) is the key letter. So, as an example: Puzzle: • ABCDEFG Valid words: • FACED • CABBAGE • BAGGAGE Invalid words: • BEEFED (doesn't include A) • BASED (S is not in the puzzle) Requirements Implement a function spelling Bee Solutions (wordlist, puzzles) that follows the function signature below

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

More Books

Students also viewed these Programming questions