Problem 53985. Check whether a Wordle guess is consistent with previous feedback
The game Wordle resembles the classic game Mastermind. Players try to guess a five-letter word, and after each guess they are told whether each letter is not in the word, in the word but not in the guessed position, or in the word and in the guessed position. Cody Problem 53960 asked us to score a letter in a guess: -1 if it is not in the word, 0 if it is but in a different position, and 1 if it is in the correct position.
In Wordle’s hard mode, the subsequent guesses must be consistent with previous feedback. If the previous guess of ZEROS receives the feedback of [-1 -1 0 1 -1], then FLOOR would be a valid guess because the second O is in the same position as before and the R is in the word but in a different position. MOURN would not be valid because the O is not in the fourth position. CAROM would not be valid because R is in the same (incorrect) position. SPOOR would not be valid because it has an S.
Pay special attention to repeated letters. If FLOOR receives the feedback of [-1 -1 0 1 -1], then ONION would be a valid guess, whereas BATON and GOODS would not be valid.
Write a function that takes the previous guess, the feedback vector, and the current guess and returns true if the current guess is consistent with the feedback and false otherwise.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers8
Suggested Problems
-
274 Solvers
-
138 Solvers
-
9583 Solvers
-
Easy Sequences 23: Hat Guessing Game!
27 Solvers
-
Determine if Input is Oddish or Evenish (Odd/Even Sum of Digits)
303 Solvers
More from this Author291
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!