Generate Wordle-style feedback for a guess against a secret word.
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
Related questions
Implement a Wordle-style generateFeedback function.Related courses


