Word Guess Feedback Colors
Problem statement
Given equal-length uppercase strings answer and guess, return one result character per guess position.
G: the character matches the answer at this position.Y: after exact matches are consumed, another unmatched copy of this character exists elsewhere in the answer.R: no unmatched copy remains.
Each answer character may be matched at most once.
Function
wordGuessFeedback(answer: String, guess: String) → StringExamples
Example 1
answer = "APPLE"guess = "ALLEY"return = "GYRYR"The two-pass rule consumes exact matches before assigning remaining copies.
Example 2
answer = "CRANE"guess = "CRANE"return = "GGGGG"The two-pass rule consumes exact matches before assigning remaining copies.
Example 3
answer = "ABCDE"guess = "FGHIJ"return = "RRRRR"The two-pass rule consumes exact matches before assigning remaining copies.
Constraints
1 <= answer.length == guess.length <= 1000.- Both strings contain uppercase English letters.