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".

Imagine, we have a couple of CNOT gates hidden in a black box. This box is prepared so, that we are not able to see which gates are inside. But we know that they follow some pattern. This pattern is given by a secret code, e.g. 110. For each and every 1 in the secret bit string there is a CNOT gate connecting the qubit at the corresponding position with an answer qubit.

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?
Measurement
What is the secret code?
In general: How many guesses does one at least need to figure out this 4 digit secret code?