Find a secret word via match feedback
MoveworksSoftware Engineer · OnsiteLast updated
This question evaluates algorithmic search, pattern-matching, and information-elimination skills in an interactive Mastermind-style word-guessing scenario, testing string comparison and combinatorial reasoning under constrained feedback.
Word Guessing Game (Mastermind-style)
You are given a list of unique candidate words wordlist. All words have the same length L and contain only lowercase letters.
There is an unknown secret word that is guaranteed to be in wordlist. You can make a guess by choosing any word from wordlist. After each guess, you receive an integer k meaning:
k= the number of positionsiwhereguess[i] == secret[i](exact position matches).
Task
Design a strategy/function that finds the secret word using at most G guesses.
Interface (conceptual)
- You can call
match(guess) -> intto get the feedbackk. - You must output the secret word (or stop once identified).
Constraints
1 <= |wordlist| <= 10001 <= L <= 10- Maximum allowed guesses
G(e.g.,G = 10)
Notes
- The interviewer may simulate
match(). - Your approach should be efficient enough to work within the guess limit.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.