Circuit puzzle
Put gates on two or three qubits until what they give matches the target.
New to qubits: start with the short guide, Quantum basics.
Puzzle 1 of 11
Hint
How to play
- Each line is one qubit, named q0, q1, and so on from the top. Its gates run from left to right.
- Select a gate below, then select a square on a line to place it there. Select the square again to take it off.
- Or drag a gate onto a square, drag a placed gate to move it, or drag it off the circuit to take it off.
You reach the target at a 100% match. The match can start above 0%, because your start and the target can already overlap.
A CNOT has a dot on one line and a ⊕ on another. It flips the ⊕ line only where the dot line is 1.
To place one, select a square for its dot. Its ⊕ goes on the line below, or above when the dot is on the bottom line. Select the ⊕ to turn the CNOT around. A CNOT fills its whole step, so it replaces any other gate in that step.
In this puzzle, a CNOT points down only: its dot is always on the upper line.
The box, marked f, hides a rule that gives 0 or 1 for each input. The box reads the top lines as its input: with one top line, the input is 0 or 1, and with two, it is 00, 01, 10, or 11. It flips the bottom line when the rule gives 1.
A constant box gives the same output for every input, and a balanced box gives 1 for exactly half of them. You do not know which box you have, so your circuit must answer right for all of them, and you may use the box only once. The box fills its whole step. You win when every box gets the right answer.
Nobody needs this answer for its own sake. It is the first problem where a quantum computer needs fewer uses of a box than any ordinary method that is always right, and the same trick sits inside larger quantum algorithms.
What you getOutput state
Your circuit Target
Each row is one result. How to read this table
| ResultBasis | DialPhase | AmountAmplitude | ChanceProbability | Counts |
|---|
How to read the output
Each row is one result you can get when you look at the qubits. Its label lists the qubits from the top of the circuit down, so |01⟩ means q0 reads 0 and q1 reads 1.
The bar is the chance of that result. The number under Amount is that part of the state, called its amplitude. Its size sets the chance: multiply the size by itself, so 0.707 × 0.707 is about 0.5. It can also carry a minus sign or an i, which set its direction on the small dial: a minus sign is a half turn, and an i is a quarter turn. The sign and the i do not change the chance, so −0.707 and 0.707i also give about 0.5. The direction is called the phase.
When you measure, you see only the bars. Two states can have the same bars and different dials. So a gate that turns only the dials looks like it does nothing, until a later gate makes the dials add up or cancel out.
Match to target says how close your output is to the target. It counts the dials as well as the bars, so it can start above 0% before you place a gate, and it reaches 100% only when both match. Turning all the dials by the same amount does not count, because no measurement can see it.
Each row is one computational basis state. The dial draws its amplitude as a vector in the complex plane: the length is the magnitude and the angle is the phase. The bar is the probability, which is the squared magnitude.
A measurement in this basis returns only the probabilities, and a global phase never shows. A relative phase changes nothing in one measurement, but a later H gate converts it into a change in probability. That conversion is interference.
The gates
H, the Hadamard gate, makes a fair coin from a 0 or a 1, and turns that coin back. X, the bit flip, swaps 0 and 1. Z, the phase flip, and S, the phase gate, turn the dial of the 1 part. CNOT, the controlled NOT, links two qubits: it flips the qubit marked ⊕ only when the qubit marked with a dot is 1. The dot can sit above or below the ⊕. The box, marked f, flips the bottom qubit when its hidden rule gives 1 for the qubits above it.
The Hadamard gate is H = (X + Z) / √2. X and Z are the Pauli X and Z gates, and X is the quantum NOT. Z = diag(1, −1) and S = diag(1, i), so S² = Z. CNOT maps |c, t⟩ to |c, t ⊕ c⟩, with any control and target. Two puzzles allow only a CNOT that targets the qubit just below its control, since their lessons need that limit. H, S, and CNOT generate the Clifford group. Add T, and the set is universal. The box is the oracle Uf|x⟩|y⟩ = |x⟩|y ⊕ f(x)⟩. It permutes the basis states, so it is unitary for any f, and it is its own inverse.