Wordle Guess Loop
Problem statement
Every supplied uppercase word has the same length and contains no repeated letters. Start with start and repeatedly make Wordle guesses until you reach answer.
After each wrong guess, compute G, Y, and _ feedback against the answer. Choose the lexicographically smallest unvisited dictionary word that would produce exactly that feedback if it were the answer. Remove each chosen word from future consideration.
Return the number of guesses including the starting guess, or -1 if no unvisited consistent word remains.
Function
countWordleGuesses(words: String[], start: String, answer: String) → intExamples
Example 1
words = ["ABCD","ACBE","AEBC"]start = "ABCD"answer = "AEBC"return = 3Feedback GYY_ first selects ACBE, then the next feedback selects AEBC.
Example 2
words = ["PHONE","HPABC","APBHC"]start = "PHONE"answer = "APBHC"return = 2APBHC is the smallest unvisited word matching the observed feedback.
Example 3
words = ["START"]start = "START"answer = "START"return = 1The starting word is already the answer.
Constraints
1 <= words.length <= 2000.1 <= words[i].length == start.length == answer.length <= 26.- Every word contains distinct uppercase English letters.
answeroccurs inwords.