Skip to main content
All Questions

Generate Wordle-style feedback for a guess against a secret word.

Unlock detailed company stats for this questionUpgrade

Build a function that generates feedback for a Wordle-style word guessing game. Compare a 5-letter guess against a 5-letter secret_word and return a 5-character string of G (correct letter, correct position), Y (correct letter, wrong position) or X (letter not in the secret word).

Examples: generateFeedback("house", "stole") -> "YXYXG"; generateFeedback("crane", "plane") -> "XXGGG"; generateFeedback("crane", "mould") -> "XXXXX".

Scale-up: implement a solver class that iteratively finds the secret word within max_attempts, refining the potential_secrets list (which is guaranteed to contain the secret) based on feedback and always picking the first word from the current list.

Expect follow-ups like

  • Scale up: implement a solver class that iteratively finds the 5-letter secret word within a maximum number of attempts, refining a list of potential secrets based on feedback and always guessing the first word from the current list.

Format · One-hour DSA round; write test cases and keep the base solution extensible for the scale-up.

Community answers

No answers contributed by the community yet.

Related courses

Course

Behavioral Interviews: A Practical Guide for Engineers

Get offers at the level you deserve. Prep for senior+ behavioral interviews at FAANG and Tier-1 companies. Made with staff and principal engineers from Meta, Netflix, Google, and more. Avoid downleveling, elevate past projects, and stop sounding like a robot.

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.