Design and implement a word-guessing game

Quick Overview

This question evaluates programming and system-design competencies such as command-line application architecture, input validation, feedback logic, state persistence for statistics, and unit testing for correctness and edge-case handling, and is categorized under System Design.

Design and implement a word-guessing game

Company: Shopify

Role: Machine Learning Engineer

Category: System Design

Difficulty: medium

Interview Round: Technical Screen

Design and implement a word-guessing game as a standalone application. Requirements: select a random secret word from a provided dictionary file; accept fixed-length alphabetic guesses via the command line; after each guess, return per-letter feedback indicating correct position, present but wrong position, or absent; enforce a maximum number of attempts (e.g., 6) and report win/lose outcomes; persist simple statistics (games played, wins, current streak) locally; write unit tests for feedback generation, input validation, word selection, and statistics updates; provide build and run instructions and explain your key design choices.

Quick Answer: This question evaluates programming and system-design competencies such as command-line application architecture, input validation, feedback logic, state persistence for statistics, and unit testing for correctness and edge-case handling, and is categorized under System Design.

|Home/System Design/Shopify
Shopify logo
Shopify
Aug 12, 2025, 12:00 AM
mediumMachine Learning EngineerTechnical ScreenSystem Design
50
0

Word-Guessing Game (Wordle-like) — Design and Implement

Context

Build a small, standalone command-line application that lets a user guess a secret word within a limited number of attempts. Treat this like a technical screen: favor clean design, testability, and clear instructions.

Functional Requirements

  1. Dictionary and secret selection
    • Read a dictionary file (one word per line).
    • Normalize and filter to a fixed length (e.g., 5 letters).
    • Select a random secret word from the filtered list.
  2. Input and validation
    • Accept guesses via the command line (interactive prompt).
    • Enforce fixed length and alphabetic-only input; be case-insensitive.
  3. Feedback per guess
    • For each letter in the guess, return feedback:
      • Correct letter in the correct position.
      • Letter present in the word but in a different position.
      • Letter not present in the word.
    • Handle duplicate letters correctly.
  4. Attempts and outcomes
    • Enforce a maximum number of attempts (e.g., 6).
    • Report win/lose outcomes at the end.
  5. Persistent statistics
    • Store locally: total games played, total wins, current streak.
    • Update after each game finishes.
  6. Tests
    • Unit tests for: feedback generation, input validation, word selection, and statistics updates.

Non-Functional/Constraints

  • Implement in a language of your choice; the result should run as a standalone CLI.
  • Keep external dependencies minimal.

Deliverables

  • Source code and dictionary file example.
  • Build and run instructions.
  • Brief explanation of key design choices.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...