Design and implement a word-guessing game
Word-Guessing Game: Design and Implementation
This challenge requires you to design and implement a standalone command-line application similar to Wordle. The application will allow a user to guess a secret word within a limited number of attempts. As this is a technical screen, prioritize clean design, testability, and clear instructions in your solution.
Functional Requirements
- Dictionary and Secret Word Selection:
- The application must read a dictionary file, where each word is on a new line.
- Words should be normalized (e.g., converted to a consistent case) and filtered to a fixed length (e.g., 5 letters).
- A random secret word must be selected from this filtered list for each game.
- User Input and Validation:
- Guesses should be accepted interactively via the command line.
- Input must be validated to ensure it is of the fixed length and contains only alphabetic characters. Input should be treated case-insensitively.
- Guess Feedback Mechanism:
- After each guess, the application must provide feedback for every letter:
- Indicate if a letter is correct and in the correct position.
- Indicate if a letter is present in the secret word but in a different position.
- Indicate if a letter is not present in the secret word at all.
- The feedback mechanism must correctly handle duplicate letters within the guess and the secret word.
- After each guess, the application must provide feedback for every letter:
- Game Attempts and Outcomes:
- A maximum number of attempts (e.g., 6) must be enforced.
- The application should clearly report whether the user won or lost at the end of the game.
- Persistent Game Statistics:
- The application must store game statistics locally, including the total number of games played, total wins, and the current winning streak.
- These statistics should be updated after each game concludes.
- Testing:
- Provide unit tests for core components such as feedback generation, input validation, word selection logic, and statistics updates.
Non-Functional Requirements and Constraints
- The application should be implemented in a language of your choice and run as a standalone command-line interface.
- External dependencies should be kept to a minimum.
Deliverables
- Source code, accompanied by an example dictionary file.
- Clear instructions on how to build and run the application.
- A brief explanation of key design choices made during development.
AI interview prep
Core dilemma
Balancing code clarity, modularity, and testability for a complex stateful game logic (especially duplicate letter handling in feedback) within a simple CLI application.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design and implement a word-guessing game
Word-Guessing Game: Design and Implementation
This challenge requires you to design and implement a standalone command-line application similar to Wordle. The application will allow a user to guess a secret word within a limited number of attempts. As this is a technical screen, prioritize clean design, testability, and clear instructions in your solution.
Functional Requirements
- Dictionary and Secret Word Selection:
- The application must read a dictionary file, where each word is on a new line.
- Words should be normalized (e.g., converted to a consistent case) and filtered to a fixed length (e.g., 5 letters).
- A random secret word must be selected from this filtered list for each game.
- User Input and Validation:
- Guesses should be accepted interactively via the command line.
- Input must be validated to ensure it is of the fixed length and contains only alphabetic characters. Input should be treated case-insensitively.
- Guess Feedback Mechanism:
- After each guess, the application must provide feedback for every letter:
- Indicate if a letter is correct and in the correct position.
- Indicate if a letter is present in the secret word but in a different position.
- Indicate if a letter is not present in the secret word at all.
- The feedback mechanism must correctly handle duplicate letters within the guess and the secret word.
- After each guess, the application must provide feedback for every letter:
- Game Attempts and Outcomes:
- A maximum number of attempts (e.g., 6) must be enforced.
- The application should clearly report whether the user won or lost at the end of the game.
- Persistent Game Statistics:
- The application must store game statistics locally, including the total number of games played, total wins, and the current winning streak.
- These statistics should be updated after each game concludes.
- Testing:
- Provide unit tests for core components such as feedback generation, input validation, word selection logic, and statistics updates.
Non-Functional Requirements and Constraints
- The application should be implemented in a language of your choice and run as a standalone command-line interface.
- External dependencies should be kept to a minimum.
Deliverables
- Source code, accompanied by an example dictionary file.
- Clear instructions on how to build and run the application.
- A brief explanation of key design choices made during development.