PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates proficiency in React-based front-end development, including state and component management, user interaction handling, and algorithmic skills for string comparison and duplicate-letter matching.

  • medium
  • Ramp
  • Coding & Algorithms
  • Software Engineer

Build a Wordle-style game in React

Company: Ramp

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

## Task Implement a simplified **Wordle-style** game as a small React app. **No styling/CSS is required** (plain HTML output is fine). ## Game rules (assume Wordle-like defaults) - The secret word is a fixed **5-letter** English word (you may hardcode it, or pass it in as a prop). - The player has at most **6 attempts** to guess the word. - Each guess must be exactly **5 letters** (A–Z). Reject/ignore invalid submissions. - After each submitted guess, show per-letter feedback: - **Correct**: the letter is in the correct position. - **Present**: the letter exists in the secret word but in a different position. - **Absent**: the letter does not exist in the secret word. - Letter matching should handle duplicates correctly (e.g., if the secret has one `A`, only one `A` in the guess can be marked as Correct/Present). ## UI/Interaction requirements - Allow the user to type a guess (e.g., an input box) and submit (e.g., Enter key or a button). - Display the history of guesses, each with its feedback (text labels are fine, e.g., `C/P/A` per character). - End state: - If the user guesses the secret word, show a “You win” message and stop accepting further guesses. - If the user uses all attempts without guessing correctly, show a “Game over” message and reveal the secret word. ## Clarifications - You may assume a single round (no need for restart unless you want to add it). - No backend is required. - No external UI libraries required. ## Example Secret: `CRANE` Guess: `CANDY` Feedback (conceptually): `C=Correct`, `A=Present`, `N=Present`, `D=Absent`, `Y=Absent`

Quick Answer: This question evaluates proficiency in React-based front-end development, including state and component management, user interaction handling, and algorithmic skills for string comparison and duplicate-letter matching.

Implement the core game engine behind a simplified Wordle-style React app. Write a function that simulates one round of the game. The function receives a secret 5-letter word and a list of submitted guesses in order. Process guesses until the player wins or 6 valid guesses have been accepted. Rules: - A valid guess is exactly 5 alphabetic characters. Invalid guesses are ignored and do not use an attempt. - Comparison is case-insensitive. - For each accepted guess, produce a 5-character feedback string using: - 'C' = correct letter in the correct position - 'P' = letter exists in the secret word but in a different position - 'A' = letter does not exist in the secret word - Duplicate letters must be handled correctly. A guessed letter can only be marked as Correct/Present as many times as it appears in the unmatched part of the secret. - Stop accepting guesses after a win or after 6 valid guesses. Return a dictionary with: - 'history': a list of (GUESS, FEEDBACK) tuples for each accepted guess, using uppercase guesses - 'status': 'win', 'game_over', or 'incomplete' - 'secret': the secret word only when status is 'game_over'; otherwise None

Constraints

  • secret is a 5-letter English word containing only alphabetic characters
  • 0 <= len(guesses) <= 10^4
  • Only guesses of length 5 containing letters A-Z count toward the 6-attempt limit
  • Processing stops immediately after a win or after 6 valid guesses

Examples

Input: ('CRANE', ['crane'])

Expected Output: {'history': [('CRANE', 'CCCCC')], 'status': 'win', 'secret': None}

Explanation: The first valid guess matches the secret exactly, so the player wins immediately.

Input: ('APPLE', ['ALLEY'])

Expected Output: {'history': [('ALLEY', 'CPAPA')], 'status': 'incomplete', 'secret': None}

Explanation: A is correct, the first L is present, the second L is absent because only one unmatched L remains in the secret, E is present, and Y is absent.

Input: ('MANGO', ['man', '12345', 'mang0', 'Mango', 'extra'])

Expected Output: {'history': [('MANGO', 'CCCCC')], 'status': 'win', 'secret': None}

Explanation: The first three submissions are invalid and ignored. 'Mango' is the first valid guess and wins the game. Later guesses are not processed.

Input: ('ROBOT', ['AAAAA', 'BBBBB', 'CCCCC', 'DDDDD', 'EEEEE', 'FFFFF', 'ROBOT'])

Expected Output: {'history': [('AAAAA', 'AAAAA'), ('BBBBB', 'AACAA'), ('CCCCC', 'AAAAA'), ('DDDDD', 'AAAAA'), ('EEEEE', 'AAAAA'), ('FFFFF', 'AAAAA')], 'status': 'game_over', 'secret': 'ROBOT'}

Explanation: After 6 valid guesses without finding the secret, the game ends and the secret is revealed. The 7th guess is ignored.

Input: ('TIGER', [])

Expected Output: {'history': [], 'status': 'incomplete', 'secret': None}

Explanation: No guesses were submitted, so the game is still incomplete.

Hints

  1. Use a two-pass approach for each guess: first mark exact matches, then use remaining letter counts to mark present letters.
  2. Keep a separate counter for valid guesses, since invalid submissions should be ignored and must not consume an attempt.
Last updated: Apr 19, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Find User Airport at a Time - Ramp (medium)
  • Find an Exit in a URL Maze - Ramp (medium)
  • Implement a multi-level digital recipe manager - Ramp (medium)
  • Find final URL by crawling until “congrats” - Ramp (hard)
  • Implement multi-level task manager APIs - Ramp (medium)