Find secret word with match-count feedback
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Technical Screen
## Problem
You are given a list of **unique** lowercase words, all of the same length (e.g., length = 6). One of these words is a **secret** word.
You can interact with a black-box API:
- `matchCount(guess) -> int`: when you submit a word `guess` from the list, the API returns the number of positions `i` such that `guess[i] == secret[i]` (i.e., exact character match at the same index).
You are allowed to call `matchCount` **at most 10 times**.
### Task
Design/implement a function (e.g., `findSecretWord(words)`) that uses the API to identify the secret word within the guess limit.
### Notes / Constraints
- `words` contains between 1 and 100 words.
- All words have equal length `L` (commonly `L = 6`).
- Every guess must be a word from `words`.
- After each API response, you may adapt your next guess.
### What to return
Depending on the interface, you may either:
- return the identified secret word, or
- stop once `matchCount(guess) == L` (found it).
(Your interviewer may treat this as an interactive problem; focus on strategy + correctness under the 10-guess constraint.)
Quick Answer: This question evaluates algorithmic reasoning and inference from constrained feedback, testing skills in information-theoretic deduction, pattern matching, and search strategy within a bounded-query interactive setting.
You are given a list of unique lowercase words, and every word has the same length `L`. Exactly one word in the list is the secret word.
In the original interview version, you interact with a black-box API:
- `matchCount(guess) -> int`
- It returns how many positions `i` satisfy `guess[i] == secret[i]`
You may call this API at most 10 times, and every guess must be a word from the given list.
In this non-interactive version, implement `solution(words, secret)` and simulate the API inside your function. The parameter `secret` is provided only so the judge can verify your strategy. Your function should repeatedly make guesses, use the returned match counts to eliminate impossible candidates, and return the discovered secret word.
If your strategy does not find the secret within 10 guesses, return an empty string `""`.
Constraints
- `1 <= len(words) <= 100`
- `1 <= len(words[i]) <= 10`
- All words are unique, lowercase, and have the same length `L`
- `secret` is guaranteed to be one of the words in `words`
- Your algorithm may use at most 10 simulated `matchCount` calls
- Test data is designed so that a correct elimination strategy can identify the secret within the limit