A quantum combination lock

To learn how quantum algorithms differ from classical ones, we need a problem that allows us to compare a quantum algorithm to its classical counterpart. The problem, we want to look at, is the problem of finding out the secret code that is behind a quantum "combination lock".

Let's imagine a black box where we can set a code, and for every 1 that occurs in the same same position as in the secret code, the answer changes (0 becomes 1, 1 becomes 0).

So in the case of the secret code 110, we would have the following two-qubit gates between guess and answer qubits:

What is the state of the answer qubit after applying the black box with the guess 101?

Cracking the black box open

Normally, we are not provided with the circuit itself and we are tasked to find out what the secret code is by guessing and looking at the answer.

Let's go for a classical solution first. Without further ado, can you figure out the secret code without opening the blackbox?

!
What is the secret 4-digit code? How many guesses do you at least need to find it?
Measurements
What is the secret code?
In general: How many guesses does one at least need to figure out this 4 digit secret code?

A quantum solution for the quantum combination lock

For a classical solution to the quantum combination lock we always needed to perform at least as much guesses as we had digits in the secret code. This is not bad. But can we get better using the properties of qubits, namely superposition and entanglement? It turns out, we can! Let's explore how.

Investigating another black box

A common way to work with quantum algorithm is to prepare an equal superposition and use it for calculation. This is also used in the Bernstein-Vazirani algorithm we want to look into now.

!
To find out the secret 4-digit code of this black box, prepare an equal superposition of all 5 qubits. Apply a set of H also after the black box.

Afterward, open the black box and check how you can retrieve the secret code from the measurement outcomes.
Measurements
Hints
What is the secret code?
  • A

    1001

  • B

    0101

  • C

    0110

  • D

    1101

How many trials does one need to figure out the correct code with the quantum algorithm?
  • A

    1

  • B

    2

  • C

    3

  • D

    4