Hard · System Design

Guess the Word

Given a list of distinct six-letter words that contains a hidden secret, and a master whose guess(word) returns how many positions word shares with the secret, call guess at most 10 times so that one call guesses the secret. No strategy that guesses from the list can always do this (26 words that differ in every position may need 26 guesses), so the list is chosen so that a careful strategy finds the secret within 10 guesses.

Examples

Example 1

{
  "secret": "acckzz",
  "words": ["acckzz", "ccbazz", "eiowzz", "abcczz"]
}

Output: { "word": "acckzz", "guesses": 1 }

Example 2

{
  "secret": "abcczz",
  "words": ["acckzz", "ccbazz", "eiowzz", "abcczz"]
}

Output: { "word": "abcczz", "guesses": 2 }

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More System Design problems