All puzzles › Quantum Computing

Quantum Computing Practice Problems

20 puzzles (9 easy, 8 medium, 3 hard), 8 free, in Python, JavaScript and C++.

Qubits, gates, superposition, Grover search, and the core ideas of quantum computing as code.

The puzzles, easiest first

  1. Do These Two Measurements Clash (Easy, free): A measurement on several qubits is written as a string of the letters I, X, Y and Z, one per qubit.
  2. Keep Only What Lined Up (Easy, free): In BB84, Alice sends each bit of a key as a photon prepared in one of two bases, written + and x, chosen at random.
  3. One Question per Bit (Easy, free): An oracle hides an n-bit secret.
  4. Outvote the Noise (Easy, free): A qubit is fragile, so one logical bit is spread across three physical ones.
  5. Two Bits Finish the Job (Easy, free): Teleporting a qubit takes a shared entangled pair and two ordinary bits.
  6. Born Rule Probabilities (Easy): Given a list of real amplitudes, return the probability of each outcome, rounded to 4 decimals.
  7. Most Likely Outcome (Easy): Given the probability of each outcome, return the index of the most likely one.
  8. Pauli-X (NOT) Gate (Easy): Given a list of qubits as 0s and 1s, apply the Pauli-X gate to each one and return the result.
  9. Superposition States (Easy): Given n qubits, return how many basis states they cover together.
  10. Find the Flip Without Looking (Medium, free): Measuring a qubit destroys what it holds, so a quantum code never looks at its data.
  11. How Many Layers Deep (Medium, free): A qubit loses its state within moments, so what matters about a quantum circuit is not how many gates it has but how many layers.
  12. Bloch Sphere Probability (Medium): Given a qubit's angle theta on the Bloch sphere, in degrees, return the chance of measuring 0, rounded to 4 decimals.
  13. CNOT Gate (Medium): Given two qubits as [control, target], apply a CNOT gate and return the new [control, target].
  14. Combined State Space (Medium): Given the dimension of each quantum system, return the dimension of all of them combined.
  15. Expectation Value (Medium): Given an observable's eigenvalues and the probability of each one, return the expectation value, rounded to 4 decimals.
  16. Grover Iterations (Medium): Given the number of items n in a search space, return the best number of Grover iterations: pi / 4 x the square root of n, rounded down.
  17. Normalize a Quantum State (Medium): Given a list of amplitudes, scale them so their squares add up to exactly 1, rounded to 4 decimals.
  18. The Period Gives It Away (Hard, free): Shor's algorithm breaks RSA by turning factoring into finding a period.
  19. Apply a Hadamard Gate (Hard): Given a single qubit's real amplitudes [a, b], apply a Hadamard gate and return the new amplitudes, rounded to 4 decimals.
  20. Grover Success Probability (Hard): Given a search space of size n and a number of Grover iterations k, return the chance of finding the marked item, rounded to 4 decimals.

Practice another pattern

Or browse by subject

Browse all 676 puzzles