Circuit Identities
Swap Across a Gap
Difficulty: Easy ★
On a linear three-qubit chip the outer qubits cannot talk directly, and the device has no native SWAP. Exchange them anyway, and leave the middle qubit exactly as you found it.
Objective
Return a three-qubit circuit whose unitary equals SWAP(q0, q2) with q1 unchanged.
Constraints
- Allowed gates: cx.
- CX only between (0, 1) or (1, 2).
- At most 9 CX gates.
Entry Point
swap_endsChecks
- Exports swap_ends().
- Uses at most 9 nearest-neighbour CX gates.
- The unitary equals SWAP(q0, q2).
Your Code
Outputpending
Execution results will appear here.