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 positions
i
where
guess[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) -> int
to get the feedback
k
.
-
You must output the secret word (or stop once identified).
Constraints
-
1 <= |wordlist| <= 1000
-
1 <= 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.