Question
? 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started