Letter-Guessing Strategy for a Program That Plays Hangman

Quick Overview

A technical question for Google product manager candidates: explain how a program could play Hangman as the guesser. It tests modeling the game state, reasoning about which words remain possible, choosing each letter, handling words outside a dictionary and measuring win rate against both fair and adversarial hosts.

Letter-Guessing Strategy for a Program That Plays Hangman

Company: Google

Role: Product Manager

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Other

You are interviewing for a product manager role at Google, and the interviewer asks a technical question: if you had to write a program that plays Hangman as the guesser, what would its algorithm look like? Describe how the program represents the game, what data it uses, how it chooses each letter, how you would judge whether it plays well, and how you would improve it. Assume the usual rules unless the interviewer changes them: - The host secretly picks a word and shows one blank for each letter. - On each turn the guesser names one letter that has not been guessed yet. - If the letter is in the word, every position where it occurs is revealed; if not, the guesser is charged one wrong guess. - The guesser wins by revealing the whole word and loses after a fixed number of wrong guesses. ```hint Use what the board rules out The revealed letters, the blanks that remain and the letters that missed all carry information. Think about what they tell you about the hidden word before deciding what to guess next. ``` ### Clarifying Questions - Is the hidden word drawn from a known dictionary, or could it be a name, slang or a phrase? - How many wrong guesses are allowed before the game is lost? - Does the host pick the word at random and keep it fixed, or might the host choose hard words, or even change the word as long as it stays consistent with earlier answers? - Should the program maximize the chance of winning or minimize wrong guesses, and are there limits on time or memory per guess? ### What a Strong Answer Covers - A precise model of the game state and of what each guess reveals, including repeated letters. - Tracking which words are still possible, with correct handling of hits, misses and blanks. - A rule for choosing the next letter, justified by its effect on winning, with its trade-offs and running cost. - A fallback for words the program's dictionary does not contain. - How to test the program over many simulated games, and how the strategy changes against a host that plays adversarially. ### Follow-up Questions - How would your algorithm change if the host could swap the hidden word at any point, provided it stays consistent with every answer given so far? - When many words remain, should the guesser prefer the letter most likely to be in the word or the letter that best separates the remaining words? When do those differ? - How would you adapt the program to multi-word phrases or to a language with accented letters?

Overview: A technical question for Google product manager candidates: explain how a program could play Hangman as the guesser. It tests modeling the game state, reasoning about which words remain possible, choosing each letter, handling words outside a dictionary and measuring win rate against both fair and adversarial hosts.

Google logo
Google
May 18, 2025
mediumProduct ManagerOtherSoftware Engineering Fundamentals
0
0

You are interviewing for a product manager role at Google, and the interviewer asks a technical question: if you had to write a program that plays Hangman as the guesser, what would its algorithm look like? Describe how the program represents the game, what data it uses, how it chooses each letter, how you would judge whether it plays well, and how you would improve it.

Assume the usual rules unless the interviewer changes them:

  • The host secretly picks a word and shows one blank for each letter.
  • On each turn the guesser names one letter that has not been guessed yet.
  • If the letter is in the word, every position where it occurs is revealed; if not, the guesser is charged one wrong guess.
  • The guesser wins by revealing the whole word and loses after a fixed number of wrong guesses.

Clarifying Questions Guidance

  • Is the hidden word drawn from a known dictionary, or could it be a name, slang or a phrase?
  • How many wrong guesses are allowed before the game is lost?
  • Does the host pick the word at random and keep it fixed, or might the host choose hard words, or even change the word as long as it stays consistent with earlier answers?
  • Should the program maximize the chance of winning or minimize wrong guesses, and are there limits on time or memory per guess?

What a Strong Answer Covers Guidance

  • A precise model of the game state and of what each guess reveals, including repeated letters.
  • Tracking which words are still possible, with correct handling of hits, misses and blanks.
  • A rule for choosing the next letter, justified by its effect on winning, with its trade-offs and running cost.
  • A fallback for words the program's dictionary does not contain.
  • How to test the program over many simulated games, and how the strategy changes against a host that plays adversarially.

Follow-up Questions Guidance

  • How would your algorithm change if the host could swap the hidden word at any point, provided it stays consistent with every answer given so far?
  • When many words remain, should the guesser prefer the letter most likely to be in the word or the letter that best separates the remaining words? When do those differ?
  • How would you adapt the program to multi-word phrases or to a language with accented letters?