Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Although it was attempted to be fixed by an earlier commit (#7), it is still incorrect
Previously, if the guess contains duplicate letters, letters in the wrong spot could appear yellow even if there is only 1 occurrence in the word.
Example:
If the answer is
"THOSE"
, if a player were to guess the word"GEESE"
, the algorithm above would produce the colors:This would imply that the correct answer has one E's in the wrong location and one E in the correct location (a total of two E's).
The result should, however, only show 1 E being in the word:
Another example:
If the answer is
"DREAD"
, and"ADDED"
is guessed, the result produced would be:This implies no letters are missing, but in fact, one of the D's is wrong and the R is missing. Only one of the wrongly placed D's should be marked Yellow.
The change I've made to the code accounts for these duplicates and produces results similar to the original Wordle.