Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Wordle-Style Guess Evaluation

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Wordle-Style Guess Evaluation. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Retool's app builder includes interactive forms where a five-letter guess can be evaluated against a hidden answer. Given an answer word and a guess word, classify every guess position as green, yellow, or _.

A position is green when the guess has the same letter as the answer at that position. A non-green guess is yellow when the letter appears elsewhere in the answer and has not already been matched by another guess position. Otherwise, mark it _. Duplicate letters must not be matched more times than they occur in the answer. Green matches take priority over yellow matches.

Formal Specification

Implement evaluate_guess(answer, guess), where both inputs are lowercase strings of exactly five English letters. Return an array of exactly five strings. Each output element must be one of green, yellow, or _, and corresponds to the same index in guess.

Constraints

  • answer and guess each have length 5
  • Both strings contain only lowercase English letters
  • Each answer occurrence can be matched at most once
  • Green matches are prioritized over yellow matches

Function Signature

def evaluate_guess(answer, guess):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output