Skip to main content

Data Structure & Algo

Cipher

Difficulty: Medium

In this challenge, you'll build a simplified Wordle game. Players attempt to determine a hidden 5-letter word within 6 attempts. After each guess, the game provides feedback to help refine their next attempt. You'll implement logic for word comparison, manage game state, and design an interactive UI.

Requirements

Target Word Selection
  • The app should randomly select a 5-letter word from the predefined list below.
apple, brace, cloud, drive, eager, flare, ghost, humid
  • Each game session should start with a freshly randomized word.
Input & Validation
  • Display a text field with a submit button for entering guesses.
  • Ensure that the submitted guess is exactly 5 letters long.
  • If the input is too short or too long, show an error message and prevent submission.
Providing Feedback

After submission, compare each letter of the guessed word with the target word and apply feedback coloring:

  • Green → Correct letter, correct position.
  • Yellow → Correct letter, wrong position.
  • Gray (unhighlighted) → Letter is not in the word.

For example, if the target word is GRAPE and the player guesses PLATE:

Letter Feedback
P Yellow (Right letter, wrong place)
L Gray (Not in the word)
A Green (Right letter, right place)
T Gray (Not in the word)
E Green (Right letter, right place)

Display the previous guesses and their feedback for reference.

Game Mechanics
  • Players have 6 attempts to guess the word.
  • After each guess, display the updated board with feedback.
  • The game ends when:
    • The player correctly guesses the word (show a success message).
    • The player uses all 6 attempts (show a failure message + reveal the correct word).
  • Provide a restart button after game completion.

Above & Beyond

Once the core mechanics are working, consider adding enhancements:

  • Animations & Effects – Smooth transitions for feedback colors.
  • Word Dictionary API – Dynamically fetch words instead of using a static list.
  • Scoring & Performance Tracking – Track player accuracy and streaks.