Wordle is a game where you are given
A hint will clarify the following for every letter of your guess:
- If a letter is not in the word, it will turn gray.
- If a letter is in the word but in the wrong spot, it will turn yellow.
- If a letter is in the word and in the right spot, it will turn green.
You are to implement a program that takes in a list of
For each guess, you will receive input indicating a hint.
In the example shown above, a hint for the guess later
will be la--*
, where -
represents gray letters and *
represents yellow letters.
Any revealed hints must be strictly used in subsequent guesses (similar to Wordle's hard mode). For example, if a hint indicates that a certain letter cannot appear in the word, then you are not allowed to guess any words containing that letter. Your submission will be correct as long as each subsequent guess does not contradict any of the previous hints provided.
Note: just like regular Wordle, if a letter appears twice in the guess, but that letter only appears once in the secret word, one of the letters will be highlighted gray (e.g. if the secret word was lore
and the guess was roll
, the hint will be *o*-
).
Constraints
Input Specification
The first line of input contains two integers
The next
The rest of the problem is interactive: input will be given based on the guesses you output.
If your guess is correct, the input will be correct!
.
If your guess contradicts any hints, the input will be wrong!
.
Otherwise, the input will be -
and *
.
Output Specification
You can make at most up to
For each guess, you must output any word from the list that satisfies all of the hints provided, followed by a newline.
After each guess, you must flush your output.
Sample Interaction
Lines preceded by >>>
represent your output. Do not output >>>
.
4 6
create
wordle
sample
simple
>>> create
---*-e
>>> sample
correct!
Explanation for Sample
Given the hint ---*-e
after arbitrarily guessing create
, we can deduce that the secret word must contain the letter a
; therefore, it cannot be wordle
or simple
.
Comments