FastPrepWordle Guess Checker
Problems/Wordle Guess Checker

Wordle Guess Checker

Patreon logoPatreon● MediumFULLTIMEPHONE SCREEN

Updated Dec 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Three reports from late 2025 and early 2026 give a Wordle task as a Patreon coding question. The December 2025 Software Engineer report describes a technical screen labelled medium: compare a guess with the secret word position by position and mark each spot G, Y or W (green, yellow, white). The interviewer's sample cases, which the candidate used to work out the real marking rule, give Example 1 and the guesses "cable" and "paple" in Example 2; "cazle" after "cable" is from the report's follow-up, while the third guess "paple" and all of Example 3 are ours. The follow-up keeps track of earlier guesses and answers invalid_input when a guess uses a letter an earlier guess marked white, as in Example 2. Read word for word, that would bar any letter once marked white, which conflicts with the report's own sample behind Example 1, where a letter of the secret word gets a white mark. The candidate adds that some edge cases had to be confirmed with the interviewer. The January 2026 Software Engineer report lists building a Wordle game, plus follow-ups it does not name; its process is a recruiter screen, then one medium coding round, after which the candidate went on to the onsite. The November 2025 Senior Android Engineer report asks for a Wordle solution in a coding exercise after a screening of simple Android questions. Stage: phone screen for each report (stated for the December 2025 screen; inferred for the January 2026 report, whose coding round was the screen before the onsite, and for the November 2025 report, which has no final-round cue). Our choices: a letter is ruled out only when an accepted guess marked every copy of it white, so a letter that is white in one spot but green or yellow in another stays allowed; a rejected guess rules out nothing; every guess is scored, even after an all-green one; there is no attempt limit or word list; the function returns one string per guess; the 5-letter length, the limit of 100 guesses and the lowercase rule are ours.

You are checking guesses in a word game. The secret word is target, and the player submits the words in guesses one after another. Every word has 5 lowercase letters.

For each guess, give every position one mark:

  • 'G' (green): the guess has the same letter as target at this position.
  • 'Y' (yellow): the letters at this position differ, but target still has an unused copy of the guessed letter somewhere else.
  • 'W' (white): the letters at this position differ, and target has no unused copy of the guessed letter left.

Repeated letters are counted, because one copy of a letter in target can account for only one position of the guess. First mark every green position; each green uses up the copy of its letter in target. Then visit the other positions from left to right: a position is yellow if target still has an unused copy of that letter, and that copy is now used up; otherwise the position is white.

The game also remembers earlier guesses. A guess that contains a ruled-out letter is rejected: its entry is the string "invalid_input" and it gets no marks.

Assumption: a letter is ruled out only when an accepted guess marks every copy of it white, which means the letter does not occur in target. A letter that is white at one position but green or yellow at another is not ruled out, and a rejected guess rules out nothing.

Return an array with one entry per guess, in order: the 5 marks of an accepted guess as one string, such as "WGWGG", or "invalid_input" for a rejected guess. Every guess is handled this way, even after a guess that is all green.

Function

scoreGuesses(target: String, guesses: String[]) → String[]

Examples

Example 1

target = "maple"guesses = ["apple"]return = ["YWGGG"]

Positions 2, 3 and 4 hold the same letters in both words, so they are green. "maple" has one 'p', and the green at position 2 uses it, so the 'p' at position 1 is white. The 'a' at position 0 is not in its place, but the 'a' of "maple" at position 1 is still unused, so it is yellow.

Example 2

target = "maple"guesses = ["cable", "cazle", "paple"]return = ["WGWGG", "invalid_input", "WGGGG"]

In "cable", positions 1, 3 and 4 are green. 'c' and 'b' do not occur in "maple", so both are white and both are now ruled out. "cazle" contains 'c', so it is rejected; its 'z' is not ruled out, because a rejected guess rules out nothing. In "paple", positions 1 to 4 are green; the green 'p' at position 2 uses the only 'p' of "maple", so the 'p' at position 0 is white.

Example 3

target = "robot"guesses = ["error", "eager", "gator", "robot"]return = ["WYWGW", "invalid_input", "WWYGY", "GGGGG"]

In "error", the 'o' at position 3 is green. 'e' does not occur in "robot", so it is white and ruled out. "robot" has one 'r' and no green uses it, so the first 'r' of the guess, at position 1, is yellow and the ones at positions 2 and 4 are white; 'r' got a yellow, so it stays allowed. "eager" contains 'e' and is rejected. In "gator", 'g' and 'a' are white, the 'o' is green, and 't' and 'r' are yellow because "robot" has an unused copy of each. The last guess matches at every position.

Constraints

  • target.length == 5
  • 1 <= guesses.length <= 100
  • guesses[i].length == 5
  • target and every guesses[i] contain only lowercase English letters.

More Patreon Phone Screen questions

  • Sliding-Window API Rate LimiterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Employee Importance from a DictionaryPHONE SCREEN · Seen Feb 2026
  • Uniform Random Number from Coin TossesPHONE SCREEN · Seen Feb 2026
  • Org Chart Report CountsPHONE SCREEN · Seen Dec 2025
  • Format the Missing Numbers from 1 to 99PHONE SCREEN · Seen Sep 2025
  • Pythagorean Triplets in an ArrayPHONE SCREEN · Seen Oct 2024
  • LRU Cache with TTLPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Password GeneratorPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
  • Merge IntervalsPHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2022
  • JSON ParserPHONE SCREEN · Seen Jun 2021

Similar questions at other companies

  • Dasher Pay with Store Waits and Peak HoursDoorDash · PHONE SCREENDoorDash interview questions
  • Invoice / Payment ReconciliationStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • Route Pattern MatcherGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • String Interpolation with a Missing-Value ModeMongoDB · PHONE SCREENMongoDB interview questions
  • Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions
  • Fixed-Order Task Run Time With CooldownWaymo · PHONE SCREENWaymo interview questions
  • Character Counts with Retried Remote WorkersCoalition · PHONE SCREEN
All Patreon interview questionsSee Patreon hiring insights
Saved
class Solution {
    public String[] scoreGuesses(String target, String[] guesses) {
        // Write your code here.
    }
}
Checking account…