Problem 53960. Wordle
Wordle is an english game where you need to guess a 5 letter word. For each guess you'll receive a feedback for the placement of each letter. If a letter is in the correct spot it will show as green, if a letter is in the word, but in the wrong spot it will show as yellow and if the letter is not present in the word it will show as black.
For this problem your inputs will be the target word and a guess, the output should be a vector corresponding to the guess word where there should be a -1 if the letter is not present in the target word, a 0 if the letter is present in the target word, but at the wrong spot, and a 1 if the letter is in the correct spot.
Example:
Target Word: 'thing'
Guess Word: 'write'
Output: [-1 -1 1 0 -1]
All inputs will be lower case and contain 5 letters.
If a letter appears more than once in the guess and only once in the target word then it should be considered correct only once. consider the correct letter the one in the correct spot if any, else the first occurence of the letter should be considered (see test cases 2,3, and 4 for examples)
Solution Stats
Problem Comments
-
3 Comments
William
on 21 Jan 2022
The values of 'y_correct' in test problems 2, 3, and 4 are incorrect.
Franco Zapata
on 21 Jan 2022
No, test cases 2, 3 and 4 were built specifically to show how your code should behave in those situations. The code should only consider the correct amount of letters. if there are 2 s's in your guess, but only one in the word, only one should be considered (the most correct one, if any, else the first one)
William
on 21 Jan 2022
Oh, I see. Thanks for the clarification!
Solution Comments
Show commentsProblem Recent Solvers8
Suggested Problems
-
2027 Solvers
-
293 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
1073 Solvers
-
Count consecutive 0's in between values of 1
435 Solvers
-
Flip the vector from right to left
9003 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!