Project 06 · Ladder 2 · Intermediate
Quantum Maze Solver: aim Grover's algorithm at a puzzle
How it works
- Every four-move path through the maze at once: 256 of them, held in 8 qubits.
- Grover's rounds fade the dead ends. The oracle checks each path without ever seeing the answer.
- Two routes survive, DDRR and RRDD, and one of them is walked to the goal.
8 qubits. 256 possible paths. One measurement hands you the way out 99.6% of the time.
- Level
- Intermediate
- Hours
- 6 to 8
- Automated tests
- 19
- Ships to
- GitHub
What you build
Quantum Maze Solver in Python and Qiskit
In Project 05 you searched a list of names. Now you aim Grover's algorithm at a puzzle. Every 4-move path becomes an 8-bit number, 8 qubits carry all 256 paths in one quantum state, and an oracle flips the sign of the paths that reach the goal without hitting a wall. Eight Grover iterations later, a measurement hands you a working route.
Then comes the boss level. You rip out the shortcut oracle and build one the way quantum engineers do, from the maze's own rules, gate by gate. It never sees the answers, it needs no extra qubits, and it compiles to about a fifth of the two-qubit gates (68 instead of 360). Finally you race everything against breadth-first search and find out exactly where quantum wins. A working quantum demo plus a real benchmark: that's the story you tell in interviews.
The quantum ideas inside
- Search-space encoding
- Gate-level oracles
- Multi-controlled Z
- Grover iterations
- Breadth-first search
New to Qiskit? Run your first circuit free, or warm up with the free Qiskit tutorials.
Real output · Project 06Qiskit Aer simulator
python quantum_maze.py --maze pillar --seed 7 --plot maze_results.png
Maze:
S..
.#.
..G
Classical BFS: shortest path RRDD (4 moves), 8 cells explored
Search space: 256 move sequences on 8 qubits, 2 valid: DDRR, RRDD
Classical brute force: 85.7 checks expected (random order), 256 to check them all
Grover: 8 iterations (oracle calls), theory P(valid) = 0.9956
Most measured path: DDRR (valid: True)
Valid-path fraction: 0.994 over 1024 shots
Chart saved to maze_results.png
By the end
What you walk away with
- an encoding that turns any 4-move path into an 8-bit number and back
- a maze-rule checker, and a Grover circuit that amplifies every path passing it
- a gate-level oracle built from CX, X and one multi-controlled Z, proved identical to the list-based one on all 256 paths
- two classical baselines: brute force over all paths, and breadth-first search
- a three-panel chart: the maze with the quantum-found path, the top measured paths, and the work each method needed
- 19 core tests and 10 bonus tests passing, a published repo, a portfolio paragraph and a LinkedIn post
Where it sits
Ladder 2: Intermediate
IntermediateLadder 2
Grover's Search
Find one name in 16 in 3 looks.
Quantum Maze Solver
An oracle that never sees the answer.
BB84 Key Distribution
Catch a spy on the line. Its inventors won the 2025 Turing Award.
Your first circuit is 10 minutes away
Stop watching quantum. Start shipping it.
$0 today. 7 days free, then $7.99 a week or $190 a year. Cancel any time.