From c56b7ab526024a826750a5f1572954e44348a0ca Mon Sep 17 00:00:00 2001 From: mcpower Date: Mon, 24 Jan 2022 22:16:07 +1100 Subject: [PATCH] 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 --- src/clue.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/clue.ts b/src/clue.ts index 3e9c43f..8df55b8 100644 --- a/src/clue.ts +++ b/src/clue.ts @@ -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;