Case

Sudoku variant generator

Our own product

A Z3-powered generator of variant sudokus — build a puzzle in the web app or from the command line, with sixteen workers racing to the first valid one.

What & why

A web app to build, save and play variant sudokus: pick from dozens of constraint types, have the Z3 solver prove a guaranteed-unique puzzle and determine the difficulty, and open it straight in SudokuPad. A library keeps every puzzle made with its constraints, difficulty and rating. The same generator also runs from the command line.

Making good variant sudokus by hand is slow and error-prone. We wanted a tool that produces a guaranteed-solvable puzzle in seconds, ready to play — and that works just as pleasantly in a polished web app as from the command line.

Approach

  1. Dozens of constraint types modelled as logical conditions for the Z3 solver.
  2. A web app to pick constraints, generate and play, with a library that keeps every puzzle made — the same generator also runs from the command line.
  3. Sixteen parallel workers (on a dedicated 16-core build host) racing to the first valid puzzle — the first wins, the rest are killed; a Braille animation shows the progress.
  4. Output that is directly solvable in SudokuPad.

Technology

  • Python
  • Z3 solver
  • Flask (web app)
  • bash
  • Parallel workers

Images & demo

In the web app

  1. The swarm searches live: sixteen workers like a field coming into bloom, until one finds a unique puzzle.
  2. A found puzzle with givens, ready to play or to open in SudokuPad.A found puzzle with givens, ready to play or to open in SudokuPad.
  3. Pick constraints, method and difficulty; Z3 proves the puzzle is uniquely solvable.Pick constraints, method and difficulty; Z3 proves the puzzle is uniquely solvable.
  4. Every puzzle made, searchable by its constraints, difficulty and rating.Every puzzle made, searchable by its constraints, difficulty and rating.

On the command line

  1. The same swarm on the command line: sixteen workers race with live Braille progress, until one wins.