Generate Word Guess Feedback
Problem statement
Given a five-letter guess and five-letter secret, return a five-character feedback string.
G: the letter is correct and in the correct position.Y: the letter is present in another position.X: the letter is absent after accounting for already matched copies.
Each copy of a secret letter may satisfy at most one guess position. Exact matches take priority over misplaced matches.
Function
generateFeedback(guess: String, secret: String) → StringExamples
Example 1
guess = "allee"secret = "apple"return = "GYXXG"The first a and final e are exact; only one l is available as a misplaced match.
Example 2
guess = "civic"secret = "vivid"return = "XGGGX"The middle three letters match exactly and neither c appears in the secret.
Constraints
guess.length == 5secret.length == 5- Both strings contain only lowercase English letters.