Question presented to candidate: "Build a Wordle clone. The player has six tries to guess a five-letter word. After each guess, colour every letter: green if it is in the right spot, yellow if it is in the word but somewhere else, grey if it is not in the word. Support the physical keyboard and an on-screen keyboard that shows the best colour found for each letter."
Requirements:
- A 6 by 5 grid; letters fill the current row as the player types; Backspace deletes; Enter submits.
- Reject guesses that are too short ("Not enough letters") or not in the word list ("Not in word list") without using up a try.
- Score each guess with correct duplicate-letter rules (for example guess "speed" against the answer "abide" gives one yellow E, not two).
- An on-screen keyboard that types too and shows each letter's best state (green beats yellow beats grey).
- Win and loss messages; the answer is revealed on a loss; New game picks another word.
What a strong answer should cover:
- A pure
score(guess, answer)with the two-pass algorithm: mark exact matches first, count the remaining answer letters, then hand out yellows left to right while copies remain. - Tricky test cases: "speed" vs "abide", "geese" vs "those", "lolly" vs "hello".
- One
applyKeyentry point shared by the physical and the on-screen keyboard; awindowkeydown listener that ignores Ctrl, Meta and Alt combinations. - Game state as one object (guesses, current text, status, message), with the board rows and keyboard colours derived.
- Injected randomness for picking the answer (a seeded RNG), and accessible output (row labels, a live region for messages).
Clarifying questions expected:
- "Where do the answers and the list of allowed guesses come from, and how big are they?"
- "Do you want hard mode, where revealed hints must be reused?"
- "Should the game persist across reloads, or be one word per day?"
Code / implementation expected: Yes. A playable game in the framework of your choice, with the scoring function separate and tested on duplicate-letter cases.