0
$\begingroup$

I have to solve the following exercise about probability:

There are $w_1, \dots, w_n$. The user changes his password after every 2s from the list of passwords he has. The hacker checks the password every 1s starting from $w_1$ to $w_n$ (once he reaches $w_n$ he starts again from $w_1$).

At the beginning the user chooses his first password, and the hacker also starts to check the passwords.

Let $T$ be the tries the hacker requires to crack the password.

I have to find the function $p_T: \mathbb{N} \to [0,1],$ where $p_T(k) = P[T = K]$.

In the solution we separate the definition in the following way, we define:

$\blacksquare$ $T = 2k$ and

$\blacksquare$ $T = 2k - 1$

with $k \geq 1$

$$ P[T = 2k] = \left( \frac{n-1}{n} \cdot \frac{n-2}{n-1} \right)^{k-1} \cdot \frac{n-1}{n} \cdot \frac{1}{n-1} = \left( \frac{n-2}{n} \right)^{k-1} \cdot \frac{1}{n} $$

and

$$ P[T = 2k - 1] = \left( \frac{n-1}{n} \cdot \frac{n-2}{n-1} \right)^{k-1} \cdot \frac{1}{n} = \left( \frac{n-2}{n} \right)^{k-1} \cdot \frac{1}{n} $$

I know it's probably about combinatorics concepts, but I really doesn't understand this raw solutions without explanations.

I would really appreciate if someone could explain to me what's behind.

1 Answers 1

1

The user's password can be $ w_1, w_2, ... , w_n $, and the user changes their password every 2 seconds. The hacker guesses the password (by trying one of the $ n $ passwords) once every second. This means that the hacker has the opportunity to try 2 passwords before the user resets their password.

On the first attempt, the probability that the hacker guesses the right password is $ \frac{1}{n} $ (i.e. there are $ n $ different passwords to choose from). If the hacker is unsuccessful on the first attempt, then the probability that the hacker guesses the right password on the second attempt is $ \frac{1}{n-1} $ (i.e. since the hacker has already tried one password, there are only $ n-1 $ different passwords to choose from). Since the user re-sets their password every 2 seconds, the same logic applies to all odd and even attempts.

Let's first consider the even cases, i.e. $ T = 2k $.

T = 2: attempt 1 is unsuccessful, attempt 2 is successful.

$ P (T=2) = \big( 1-\frac{1}{n} \big) \times \frac{1}{n-1} = \frac{n-1}{n} \times \frac{1}{n-1} = \frac{1}{n} $

T = 4: attempts 1-3 are unsuccessful, attempt 4 is successful.

$ P (T=4) = \big( 1-\frac{1}{n} \big)^2 \times \big( 1 - \frac{1}{n-1} \big) \times \frac{1}{n-1} = \big( \frac{n-2}{n} \big) \times \frac{1}{n} $

T = 6: attempts 1-5 are unsuccessful, attempt 6 is successful.

$ P (T=6) = \big( 1-\frac{1}{n} \big)^3 \times \big( 1 - \frac{1}{n-1} \big)^2 \times \frac{1}{n-1} = \big( \frac{n-2}{n} \big)^2 \times \frac{1}{n} $

This generalizes to:

$$ P(T=2k) = \Big( \frac{n-2}{n} \Big)^{k-1} \times \frac{1}{n} $$

You can do the same for the odd cases...

  • 0
    Thanks for the answer, it's more clear right now!2017-01-05