Hide

Problem G
Wordle Feedback

Wordle is a single-player word-guessing computer game developed by Josh Wardle, and later purchased by The New York Times. In each Wordle game instance, the player is given six attempts to guess a secret $5\textrm{-letter}$ word. On each attempt, the player simply enters a $5\textrm{-letter}$ guess (which must be a real $5\textrm{-letter}$ word), and then the game gives feedback about the correctness of the guess by assigning a colour to each letter in the guess as follows:

  • if the letter appears in the secret word in the same position, it is assigned green

  • if the letter appears in the secret word, but not in the same position, it is assigned yellow

  • if the letter does not appear in the secret word, it is assigned gray

There is one situation that requires a refinement of the above feedback rule. Suppose a letter appears $x$ times in the secret word, and $y$ times in the guess, with $1 \leq x < y$. And suppose $g$ of the occurrences of the letter in the guess are assigned green $(\textrm{clearly }g < y)$. Then there are $y-g$ remaining occurrences of the letter in the guess, but only $x-g$ remaining occurrences of the letter in the secret word. Wordle will colour the leftmost $x-g$ of these $y-g$ occurrences in the guess yellow, and the rest gray. For an example of this situation, see Sample Input/Output 3.

Given a secret word and a guess, determine the resulting Wordle feedback.

Input

The input consists of two lines, the first of which contains a secret word, and the second of which contains a guess. Each is a string of $5$ uppercase English letters (AZ). Even though Wordle stipulates that secret words and guesses must be real words, for the purpose of this problem the input may be any two $\textrm{length-}5$ strings.

Output

Output a string consisting of $5$ characters, representing the colors assigned to the letters in the guess, in the same order. Use ‘G’ for green, ‘Y’ for yellow, and ‘-’ (hyphen) for gray.

Sample Input 1 Sample Output 1
HELLO
EARTH
Y---Y
Sample Input 2 Sample Output 2
CHUMP
CHAMP
GG-GG
Sample Input 3 Sample Output 3
GUESS
SASSY
Y--G-

Please log in to submit a solution to this problem

Log in