Word-Guessing Game (Wordle-like) — Design and Implement
Context
Build a small, standalone command-line application that lets a user guess a secret word within a limited number of attempts. Treat this like a technical screen: favor clean design, testability, and clear instructions.
Functional Requirements
-
Dictionary and secret selection
-
Read a dictionary file (one word per line).
-
Normalize and filter to a fixed length (e.g., 5 letters).
-
Select a random secret word from the filtered list.
-
Input and validation
-
Accept guesses via the command line (interactive prompt).
-
Enforce fixed length and alphabetic-only input; be case-insensitive.
-
Feedback per guess
-
For each letter in the guess, return feedback:
-
Correct letter in the correct position.
-
Letter present in the word but in a different position.
-
Letter not present in the word.
-
Handle duplicate letters correctly.
-
Attempts and outcomes
-
Enforce a maximum number of attempts (e.g., 6).
-
Report win/lose outcomes at the end.
-
Persistent statistics
-
Store locally: total games played, total wins, current streak.
-
Update after each game finishes.
-
Tests
-
Unit tests for: feedback generation, input validation, word selection, and statistics updates.
Non-Functional/Constraints
-
Implement in a language of your choice; the result should run as a standalone CLI.
-
Keep external dependencies minimal.
Deliverables
-
Source code and dictionary file example.
-
Build and run instructions.
-
Brief explanation of key design choices.