Skip to content

Add 3x3 Sudoku — Grover's Algorithm notebook to games/#187

Open
y2sud wants to merge 1 commit intoqiskit-community:masterfrom
y2sud:add-3x3-sudoku-grover
Open

Add 3x3 Sudoku — Grover's Algorithm notebook to games/#187
y2sud wants to merge 1 commit intoqiskit-community:masterfrom
y2sud:add-3x3-sudoku-grover

Conversation

@y2sud
Copy link
Copy Markdown

@y2sud y2sud commented Apr 14, 2026

Summary

This PR adds a new Jupyter notebook to the games/ folder demonstrating Grover's algorithm applied to a 3×3 Latin-square Sudoku puzzle.

  • Notebook: games/3x3_sudoku_grover.ipynb
  • One-liner: Solves a 3×3 Latin-square Sudoku using Grover's algorithm.

What the notebook covers

  • Encodes 6 unknown Sudoku cells as 2-qubit variables (00→0, 01→1, 10→2), totalling 22 qubits (12 variable + 9 clause ancillae + 1 output)
  • Builds a phase-kickback oracle that marks valid Latin-square solutions by checking all 15 row/column inequality constraints via neq_pair and neq_const gadgets (compute → kick → uncompute pattern)
  • Prepares each cell in a restricted superposition (1/√3)(|00⟩+|01⟩+|10⟩) to exclude the invalid |11⟩ codeword
  • Runs the optimal number of Grover iterations (k ≈ (π/4)·√(N/M), N=729, M=2) and measures the circuit on Qiskit Aer
  • Displays results as a colour-coded histogram: green bars = valid solutions, blue = non-solutions

Changes

  • games/3x3_sudoku_grover.ipynb — new notebook
  • games/README.md — added entry for the new notebook under Contents

Dependencies

qiskit >= 1.0, qiskit-aer >= 0.14, matplotlib >= 3.7 — all standard Qiskit ecosystem packages.

Testing

Runs end-to-end on a standard laptop in under one minute using the Aer statevector simulator. Both valid solutions ([1,2,0,2,0,1] and [2,0,1,1,2,0]) are consistently the top-ranked measurements.

Adds a 22-qubit Qiskit/Aer notebook that solves a 3x3 Latin-square
Sudoku using Grover's algorithm. Demonstrates oracle construction via
neq_pair/neq_const gadgets, phase kickback, and amplitude amplification.
Also updates games/README.md with an entry for the new notebook.
@y2sud y2sud requested review from 1ucian0 and davide710 as code owners April 14, 2026 05:53
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 14, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants