There is a safe that can be opened by entering a secret code consisting of $n$ digits, each of them is $0$ or $1$. Initially, $n$ zeros were entered, and the safe is closed (so, all zeros is not the secret code).

In one attempt, you can enter an arbitrary sequence of $n$ digits, each of them is $0$ or $1$. If the entered sequence matches the secret code, the safe will open. If the entered sequence matches the secret code in more positions than the previously entered sequence, you will hear a click. In any other cases the safe will remain locked and there will be no click.

Find the smallest number of attempts that is sufficient to open the safe in all cases.
1. **Initial Setup**: The secret code consists of \( n \) digits, each being either 0 or 1. Initially, the code entered is \( 000\cdots0 \) (all zeros), and the safe is closed. The goal is to determine the smallest number of attempts required to open the safe.

2. **Strategy**: 
   - On the first attempt, enter the sequence \( 100\cdots0 \) (1 followed by \( n-1 \) zeros).
   - If the safe clicks, then \( x_1 = 1 \). If it does not click, then \( x_1 = 0 \).
   - On the second attempt, enter \( x_1 100\cdots0 \) (where \( x_1 \) is the value determined from the first attempt).
   - If the safe clicks, then \( x_2 = 1 \). If it does not click, then \( x_2 = 0 \).
   - Continue this process for each subsequent digit.

3. **Generalization**:
   - After \( k \) moves, we know the values of \( x_1, x_2, \ldots, x_k \).
   - On the \( k+1 \)-st move, enter \( x_1 x_2 \cdots x_k 100\cdots0 \) (where the remaining digits are zeros).
   - Determine \( x_{k+1} \) based on whether the safe clicks or not.

4. **Final Move**:
   - If the largest index that is 1 is \( j < n \), then after entering \( x_1 x_2 \cdots x_{j-1} 100\cdots0 \), the safe will open.
   - Otherwise, on the \( n \)-th move, enter \( x_1 x_2 \cdots x_{n-1} 1 \) to open the safe.

5. **Lower Bound Proof**:
   - Consider the set of \( 2^n - 1 \) possible sequences of \( n \) digits (excluding the all-zero sequence).
   - Define "remaining sequences" as the subset of sequences that could still be the secret code.
   - Each attempt divides the remaining sequences into two parts: those with more matches and those with no more matches than the previous attempt.
   - If the safe does not click, sequences with more matches are eliminated. If it clicks, sequences with no more matches are eliminated.
   - After each attempt, at most half of the remaining sequences can be eliminated.
   - Initially, there are \( 2^n - 1 \) sequences. After one attempt, at least \( 2^{n-1} - 1 \) sequences remain. After \( n-1 \) moves, at least \( 2^{n-(n-1)} - 1 = 1 \) sequence remains.
   - Thus, one more attempt is needed to open the safe, making a total of at least \( n \) attempts.

\(\blacksquare\)

The final answer is \( \boxed{ n } \).