PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Google

Choose optimal guesses for green-only Wordle

Last updated: Mar 29, 2026

Quick Overview

This question evaluates probabilistic reasoning, expected-value optimization, information partitioning, and algorithmic efficiency in selecting guesses under partial (green-only) feedback; it belongs to the Coding & Algorithms domain, specifically search and probabilistic modeling, and emphasizes practical algorithm design and implementation rather than purely theoretical concepts. It is commonly asked to assess a candidate's ability to model uncertainty with weighted distributions, minimize the expected remaining search space, and manage time/space trade-offs for inputs up to several thousand words.

  • medium
  • Google
  • Coding & Algorithms
  • Software Engineer

Choose optimal guesses for green-only Wordle

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem You are playing a simplified 5-letter word guessing game. - There is a hidden **secret** word of length **5**. - You have a **dictionary** of valid 5-letter words. Each word may also have an associated **frequency/weight** representing how likely it is to be the secret. - When you **guess** a 5-letter word, the game returns **only “green” information** (correct letter in the correct position). There is **no** information about letters that exist in the word but are in the wrong position (“yellow”), and no explicit info about letters that are absent. ### Feedback definition For a guess `g` and secret `s`, define the feedback as a 5-bit mask `m` where: - `m[i] = 1` iff `g[i] == s[i]` - otherwise `m[i] = 0` Example: `g="crane"`, `s="cared"` → mask is `1 0 0 0 0` (only position 0 matches). ## Task Given: - `words`: a list of `N` valid 5-letter words - `weight[w]` (optional): a positive number for each word (if omitted, assume uniform) - `candidates`: the current set of possible secret words consistent with feedback so far (initially all `words`) Write an algorithm/function to choose the **next guess** that is optimal under the following objective: - Choose a guess word `g` (typically from `words`) that **minimizes the expected size** of the remaining candidate set after receiving the green-only mask, where the expectation is taken over the secret word drawn from `candidates` according to `weight`. Formally, if `C` is the current candidate set and `C_m(g)` is the subset of candidates that would produce mask `m` for guess `g`, choose `g` that minimizes: \[ \mathbb{E}[|C_{mask}(g)|] = \sum_{m \in \{0,1\}^5} P(mask=m) \cdot |C_m(g)| \] where \(P(mask=m)\) is induced by the weighted distribution over secrets in `C`. ## Input/Output expectations - Input sizes: `1 ≤ N ≤ 5,000` (you may propose optimizations if needed), word length is always 5. - Output: the selected next guess word. ## Follow-ups (optional) - How would you incorporate non-uniform word frequencies? - How would you scale if `N` is very large (e.g., 100k)? - How would you change the objective to minimize expected **number of guesses** instead of expected remaining candidates?

Quick Answer: This question evaluates probabilistic reasoning, expected-value optimization, information partitioning, and algorithmic efficiency in selecting guesses under partial (green-only) feedback; it belongs to the Coding & Algorithms domain, specifically search and probabilistic modeling, and emphasizes practical algorithm design and implementation rather than purely theoretical concepts. It is commonly asked to assess a candidate's ability to model uncertainty with weighted distributions, minimize the expected remaining search space, and manage time/space trade-offs for inputs up to several thousand words.

Related Interview Questions

  • Solve Rooms and Top-K Streams - Google (medium)
  • Find Containing Range - Google (medium)
  • Rearrange Tasks With Cooldown - Google (medium)
  • Implement Employee Management and Expression Evaluation - Google (medium)
  • Solve Three Array and Matrix Path Problems - Google (medium)
Google logo
Google
Oct 14, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
4
0
Loading...

Problem

You are playing a simplified 5-letter word guessing game.

  • There is a hidden secret word of length 5 .
  • You have a dictionary of valid 5-letter words. Each word may also have an associated frequency/weight representing how likely it is to be the secret.
  • When you guess a 5-letter word, the game returns only “green” information (correct letter in the correct position). There is no information about letters that exist in the word but are in the wrong position (“yellow”), and no explicit info about letters that are absent.

Feedback definition

For a guess g and secret s, define the feedback as a 5-bit mask m where:

  • m[i] = 1 iff g[i] == s[i]
  • otherwise m[i] = 0

Example: g="crane", s="cared" → mask is 1 0 0 0 0 (only position 0 matches).

Task

Given:

  • words : a list of N valid 5-letter words
  • weight[w] (optional): a positive number for each word (if omitted, assume uniform)
  • candidates : the current set of possible secret words consistent with feedback so far (initially all words )

Write an algorithm/function to choose the next guess that is optimal under the following objective:

  • Choose a guess word g (typically from words ) that minimizes the expected size of the remaining candidate set after receiving the green-only mask, where the expectation is taken over the secret word drawn from candidates according to weight .

Formally, if C is the current candidate set and C_m(g) is the subset of candidates that would produce mask m for guess g, choose g that minimizes:

E[∣Cmask(g)∣]=∑m∈{0,1}5P(mask=m)⋅∣Cm(g)∣\mathbb{E}[|C_{mask}(g)|] = \sum_{m \in \{0,1\}^5} P(mask=m) \cdot |C_m(g)|E[∣Cmask​(g)∣]=∑m∈{0,1}5​P(mask=m)⋅∣Cm​(g)∣

where P(mask=m)P(mask=m)P(mask=m) is induced by the weighted distribution over secrets in C.

Input/Output expectations

  • Input sizes: 1 ≤ N ≤ 5,000 (you may propose optimizations if needed), word length is always 5.
  • Output: the selected next guess word.

Follow-ups (optional)

  • How would you incorporate non-uniform word frequencies?
  • How would you scale if N is very large (e.g., 100k)?
  • How would you change the objective to minimize expected number of guesses instead of expected remaining candidates?

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Google•More Software Engineer•Google Software Engineer•Google Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.