Ultra Hard: prevent using letter in a previously grey position (#54)

For example, with a target word of RALLY ([challenge link]), guessing
ARRAY gives [elsewhere, elsewhere, absent, absent, correct].
This commit makes guessing SPRAY a violation, as we know that A cannot
be in the first or fourth positions (or else one of them would be
correct), and R cannot be in the second or third positions.

[challenge link]: https://hellowordl.net/?challenge=cmFsbHk
This commit is contained in:
mcpower 2022-01-24 22:16:07 +11:00 committed by GitHub
parent 32be1606cf
commit c56b7ab526
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,11 +77,12 @@ export function violation(
} else if (clue === Clue.Elsewhere) {
if (!guess.includes(letter)) {
return "Guess must contain " + upper;
} else if (difficulty === Difficulty.UltraHard && guess[i] === letter) {
return nth + " letter can't be " + upper;
}
}
if (difficulty === Difficulty.UltraHard) {
if (clue !== Clue.Correct && guess[i] === letter) {
return nth + " letter can't be " + upper;
}
const clueCount = clues.filter(
(c) => c.letter === letter && c.clue !== Clue.Absent
).length;