Sudoku

Phase 1 — Sudoku Core Data & Validation

Implement the immutable puzzle backbone with strict rule checks. Keep logic UI-agnostic and testable. Provide safe setters that reject illegal digits and preserve givens. Establish clear errors and predicates for row/column/subgrid validity.

  • 9×9 grid structure with None for empties
  • Row/column/3×3 subgrid validators
  • Safe set_cell(row, col, digit) enforcing constraints
  • Immutable “givens” tracking
  • Unit tests for validators and setters

Functional result: invalid placements are rejected; valid placements succeed; validators return expected booleans on curated test cases.


Phase 2 — Puzzle Loading, Givens & Solved Check

Add puzzle I/O and state predicates. Load predefined puzzles (embedded list/CSV), mark givens read-only, and detect solved state. Include consistency checks that verify the puzzle’s starting legality before play.

  • Loader for puzzles (string/CSV → grid)
  • Givens detection and protection
  • is_solved() verifying full, valid grid
  • Start-state consistency validator
  • Tests for loader, givens, solved predicate

Functional result: loading a sample puzzle locks givens; a known solved grid returns True on is_solved(); illegal start states raise clear errors.


Phase 3 — Minimal Tkinter GUI & Interaction

Render the board and enable basic play without helpers. Support cell selection, digit entry (1–9), backspace to clear, and live conflict highlighting. Keep rendering responsive and decoupled from core logic.

  • Tkinter window with 9×9 drawing
  • Mouse selection + keyboard input (1–9, clear)
  • Highlight row/column/subgrid conflicts
  • Read-only givens styling
  • Graceful error messages on invalid input

Functional result: user selects cells, types digits, conflicts highlight immediately, and givens cannot be edited.


Phase 4 — Countdown & End Conditions

Add a visible countdown timer controlling game end. Show modal dialogs when time expires or the puzzle is solved. Allow quick restart of the current puzzle; no extra helpers or analytics.

  • Countdown display (mm:ss), one-second ticks
  • Start/pause/stop tied to game state
  • Win detection → “You won” dialog
  • Timeout → “Time’s up” dialog
  • Restart current puzzle action

Functional result: timer decreases; solving triggers win dialog; zero time triggers timeout dialog; restart resets grid and timer.