Build a Wordle-style game in React
Company: Ramp
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Online Assessment
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.
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.
Hints
- Use a two-pass approach for each guess: first mark exact matches, then use remaining letter counts to mark present letters.
- Keep a separate counter for valid guesses, since invalid submissions should be ignored and must not consume an attempt.