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.
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).
Design a strategy/function that finds the secret word using at most G guesses.
match(guess) -> int
to get the feedback
k
.
1 <= |wordlist| <= 1000
1 <= L <= 10
G
(e.g.,
G = 10
)
match()
.