Reported June 2024
Retoolstring

Next Consistent Wordle Guess

Reported by candidates from Retool's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Retool OA. Under 2s to a working solution.
Founder's read

Retool reported this one in June 2024, and the whole solution hinges on a set of letters per word. The task: given a previous Wordle guess and its G/Y/_ feedback, find the lexicographically smallest different dictionary word that would produce exactly that feedback. Because every word has distinct letters, the feedback rules get simple. No duplicate-letter headaches. If your OA is coming up, this is a filter-and-compare problem, not a clever algorithm problem. StealthCoder sits invisibly as a safety net if you blank on the live OA, but the logic below should be enough to get you moving.

The problem

All supplied uppercase words have equal length and distinct letters. Given a previous guess and its G, Y, and _ feedback, return the lexicographically smallest different dictionary word that could be the answer.
A candidate is consistent when comparing it as the answer against previousGuess produces exactly the supplied feedback. Return the empty string if no different candidate is consistent.

Function
nextWordleGuess(previousGuess: String, feedback: String, words: String[]) → String

Examples
Example 1
previousGuess = "ABCD"
feedback = "GYY_"
words = ["ACBE","AEBC","AXYZ","ABCD"]
return = "ACBE"
ACBE and AEBC are consistent; ACBE is lexicographically smaller.
Example 2
previousGuess = "PHONE"
feedback = "YY___"
words = ["HPABC","APBHC","PHONE"]
return = "APBHC"
Both nonvisited words relocate P and H; APBHC sorts first.
Example 3
previousGuess = "ABC"
feedback = "GGG"
words = ["ABC","ABD"]
return = ""
The only consistent word is the excluded prior guess.

Constraints
1 <= words.length <= 100000.
1 <= previousGuess.length == feedback.length <= 26.
All words and the previous guess contain distinct uppercase letters and have the feedback length.
Feedback contains only G, Y, and _.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to simulate the feedback for each candidate against the previous guess and compare it to the supplied string. Since letters are distinct, for each position i: if candidate[i] equals guess[i], expect G. Else if candidate[i] appears anywhere in the guess, expect Y. Otherwise expect _. Build a set of the guess letters (or a 26-size boolean array) so each check is O(1). Total work is O(N * L) with N up to 100000 and L up to 26, which is fine. Skip the word equal to previousGuess, then track the smallest consistent word with plain string comparison. No sorting needed. The common pitfall is forgetting to exclude the previous guess itself, as Example 3 shows. Another is returning null instead of an empty string. If you freeze mid-OA, StealthCoder can hand you this loop, but you can write it in ten lines.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Next Consistent Wordle Guess cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Retool's OA.

Retool reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Next Consistent Wordle Guess FAQ

How hard is the Retool Next Consistent Wordle Guess problem really?+

Easy to low-medium. The distinct-letter guarantee removes the hard part of real Wordle feedback, which is handling repeated letters. You just loop over words, compute expected feedback per position, and compare. The risk is sloppy edge cases, not the algorithm.

What's the core trick?+

Store the previous guess letters in a set. For each candidate position, G means same letter at same index, Y means the letter is in the guess but at a different index, and underscore means the letter isn't in the guess at all. Compare the built string to the feedback.

Do I need to sort the dictionary?+

No. Sorting costs O(N log N) and gains nothing. Scan once, keep the best consistent word, and replace it whenever a new consistent word compares smaller lexicographically. Linear scan is cleaner and faster.

What edge cases should I test?+

Test the case where the only consistent word is the previous guess itself, which must return an empty string. Also test all-underscore feedback, all-G feedback, and a single-letter word. Check that you return an empty string rather than null when nothing matches.

How do I prepare for this in 48 hours?+

Write the feedback simulator from scratch twice, then run the three examples by hand. Practice general string-matching and set-lookup problems with exact-output rules. This pattern is simple filtering, so accuracy on edge cases matters more than speed tricks.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Retool.

OA at Retool?
Invisible during screen share
Get it