KatInterview

Design a Distributed Crossword Fill Engine

System DesignModel answer
HardModel answerSystem Designsystem-designdistributed-systemsconstraint-satisfaction

Last updated

Architect a scalable, fault-tolerant distributed system to solve large constraint-satisfaction crossword grid fills using parallel search strategies.

Design a distributed system that solves $N \times N$ crossword puzzle fills given an input grid pattern (with black cells and optional pre-filled letters) and a large lexicon of valid words.

The system should explore the combinatorial search space efficiently, distributing work across a cluster of compute nodes while guaranteeing quick termination upon discovering a valid fill or proving that no valid fill exists.

System Requirements

Functional Requirements

  • Accept grid definitions ($N \times N$, up to $20 \times 20$) and target lexicon identifiers or custom word lists.
  • Perform constraint-satisfaction exploration to find a complete, valid grid assignment or return UNSATISFIABLE.
  • Support asynchronous job submission, execution monitoring, and cancellation.

Non-Functional Requirements

  • Scalability: Handle grid sizes up to $20 \times 20$ (~150 intersecting word slots) and dictionaries containing over 500,000 words.
  • Low Latency & High Throughput: Minimize search time by eliminating remote network calls inside tight inner solver loops.
  • Fault Tolerance: If any compute node crashes while processing a branch of the search tree, no work should be lost permanently and no duplicate invalid work should corrupt the result.
  • Resource Limits: Gracefully handle unsolvable or overly complex puzzles via configurable time and compute budgets.

Hints

Hint 1

Consider how the dictionary is queried. Is a remote database lookup feasible inside a backtracking loop exploring millions of states per second?

Hint 2

How can you represent subproblems concisely so that nodes do not need to ship full grid states across the network?

Hint 3

What mechanism ensures work remains balanced when some branches terminate in milliseconds while others take hours?