Problem statement
Design the object model and core APIs for a Sudoku engine that powers a puzzle app: it holds a board, tells the player whether their entries are legal, and can both solve and generate puzzles. Model the standard 9x9 board but keep the design generalizable to any NxN grid whose box side is the square root of N (4x4, 16x16).
Operating context. A single in-process library, no network. A board is a grid of cells; each cell is either a fixed clue (a "given") supplied when the puzzle is created or a player-entered value that can be typed, changed, and cleared. Some cells start empty. The three Sudoku constraints must hold: no value repeats within a row, within a column, or within a box (the sqrt(N)-by-sqrt(N) sub-square). The engine offers three jobs on top of the model: validate the current board, solve a board from its givens, and generate a fresh puzzle at a requested difficulty. Both solving and generating are algorithms that the caller may want to swap.
Out of scope. Persistence and save files, the rendering / UI layer and input widgets, undo-redo history, hint or auto-fill features, timing and scoring, multiplayer, and variant boards with non-square boxes or extra constraints (killer, diagonal) — model the in-process object graph, not the app around it.
What to produce. The class hierarchy (entities such as Board and Cell; value objects such as a coordinate and a value; services such as Validator, Solver, and Generator), the public APIs each class exposes, and the explicit state transitions for a cell (empty <-> filled, and why a given can never change). Be explicit about: how the row / column / box constraints are checked and how an illegal placement is reported, how the givens are made immutable so player edits can never overwrite a clue, how the solving algorithm sits behind an interface so a new solver drops in without touching the board, and how a generator produces a uniquely-solvable puzzle at a target difficulty by reusing the solver.
Requirements
This assessment is a Premium feature.
The statement above is free to read. The functional and non-functional requirements, and the graded canvas that scores your design against them, come with Premium.
Topics
- System Design LLD
- Patterns Strategy
- Oop Solid
- Extensibility
- Testability Clock