Find a secret word via match feedback
Word Guessing Game (Mastermind-style)
You are provided with a list of wordlist containing unique candidate words. All words in this list share the same length L and consist solely of lowercase English letters.
An unknown secret word exists, and it is guaranteed to be present within the wordlist. Your objective is to discover this secret word.
You can interact with the system by making a guess: choose any word from the wordlist. After each guess, you will receive an integer k. This k value represents the number of positions i where your guess[i] exactly matches secret[i].
Task
Design a strategy or implement a function that successfully identifies the secret word within a maximum of G guesses.
Interface
You can invoke a conceptual match(guess) function, which returns an integer k as described above. Your function should output the identified secret word, or terminate once it has been found.
Constraints
1 <= |wordlist| <= 10001 <= L <= 10- Maximum allowed guesses
G(e.g.,G = 10)
Notes
- The interviewer will simulate the
match()function. - Your chosen approach must be efficient enough to adhere to the given guess limit
G.
AI interview prep
Core dilemma
Optimizing information gain per guess to minimize the worst-case number of guesses required to identify the secret word from a finite set, given a strict guess limit.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Find a secret word via match feedback
Word Guessing Game (Mastermind-style)
You are provided with a list of wordlist containing unique candidate words. All words in this list share the same length L and consist solely of lowercase English letters.
An unknown secret word exists, and it is guaranteed to be present within the wordlist. Your objective is to discover this secret word.
You can interact with the system by making a guess: choose any word from the wordlist. After each guess, you will receive an integer k. This k value represents the number of positions i where your guess[i] exactly matches secret[i].
Task
Design a strategy or implement a function that successfully identifies the secret word within a maximum of G guesses.
Interface
You can invoke a conceptual match(guess) function, which returns an integer k as described above. Your function should output the identified secret word, or terminate once it has been found.
Constraints
1 <= |wordlist| <= 10001 <= L <= 10- Maximum allowed guesses
G(e.g.,G = 10)
Notes
- The interviewer will simulate the
match()function. - Your chosen approach must be efficient enough to adhere to the given guess limit
G.