This question evaluates implementation skills in managing stateful systems and data structures for pattern matching, as well as algorithmic and adversarial reasoning about information gain and search strategies when the secret can change.
Two players play a word guessing game.
misses
list
The interviewer will provide an example interaction to confirm behavior.
Design and implement data structures and functions to support:
_ _ a _ a
)
secretWord
, then a sequence of guessed letters
{ result: "hit"|"miss", pattern, misses }
Now Player A is allowed to change the secret word during the game, as long as it remains consistent with all previous responses (hits/misses and revealed pattern).
Player B wants to minimize the number of guesses needed to fully determine the word.
Discuss an approach and write high-level pseudocode for the strategy Player B should use.
Assumptions you may make (state clearly):