Implement Wordle-style word guessing solver
Problem Description
Implement a program to solve a Wordle-style word guessing game. The game involves a hidden target word of a fixed length (e.g., 5 characters), which is chosen from a known dictionary. After each guess, the program receives per-character feedback indicating:
- Correct: The letter is correct and in the right position.
- Present: The letter exists in the word but is in a different position.
- Absent: The letter does not exist in the word at all.
Requirements
- The program must continue guessing until the target word is solved or a predefined maximum number of attempts is reached.
- Design appropriate data structures and an algorithm to efficiently maintain and prune the set of possible candidate words after receiving feedback from each guess.
- Correctly handle complex feedback scenarios, including words with repeated letters and seemingly conflicting feedback (e.g., one instance of a letter is marked "Present" while another instance of the same letter is marked "Absent").
- Propose and implement a strategy for choosing the next guess. This strategy should be justified (e.g., using a frequency-based heuristic or an information-gain approximation).
- Provide a clear interface for the solver:
solve(dictionary, feedback_api, max_attempts) -> (final_guess, num_attempts). Thefeedback_api(guess)function will return the per-character feedback for a given guess. - Analyze the time and space complexity of the proposed solution.
- Include unit tests and demonstrate a sample run of the solver.
AI interview prep
Core dilemma
Balancing the computational cost of efficiently pruning a large dictionary with the effectiveness of the guessing strategy to minimize the number of attempts.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Implement Wordle-style word guessing solver
Problem Description
Implement a program to solve a Wordle-style word guessing game. The game involves a hidden target word of a fixed length (e.g., 5 characters), which is chosen from a known dictionary. After each guess, the program receives per-character feedback indicating:
- Correct: The letter is correct and in the right position.
- Present: The letter exists in the word but is in a different position.
- Absent: The letter does not exist in the word at all.
Requirements
- The program must continue guessing until the target word is solved or a predefined maximum number of attempts is reached.
- Design appropriate data structures and an algorithm to efficiently maintain and prune the set of possible candidate words after receiving feedback from each guess.
- Correctly handle complex feedback scenarios, including words with repeated letters and seemingly conflicting feedback (e.g., one instance of a letter is marked "Present" while another instance of the same letter is marked "Absent").
- Propose and implement a strategy for choosing the next guess. This strategy should be justified (e.g., using a frequency-based heuristic or an information-gain approximation).
- Provide a clear interface for the solver:
solve(dictionary, feedback_api, max_attempts) -> (final_guess, num_attempts). Thefeedback_api(guess)function will return the per-character feedback for a given guess. - Analyze the time and space complexity of the proposed solution.
- Include unit tests and demonstrate a sample run of the solver.