12. Winter Camp. In the winter camp, Vanya and Grisha live in a room. Every evening they draw lots to decide who will turn off the light before going to bed: the switch is near the door, and the loser has to go to bed in complete darkness, bumping into chairs.

Usually, Vanya and Grisha draw lots without any complications, but this time Grisha came up with a special way to draw lots:

- Let's toss a coin. If an eagle (heads) comes up on any even throw, we stop tossing: I win. If a tail (tails) comes up on any odd throw, you win.

a) (from 8th grade, 2 points). What is the probability of Grisha winning?

b) (from 8th grade, 2 points). Find the expected number of coin tosses until the end of the draw.
Solution. a) Let's assume that heads in a coin toss give a one, and tails give a zero in the fractional part of a binary fraction. This results in some number $x$ represented by a binary fraction. For example, if the sequence of tosses starts with HTH, then the binary fraction is 0.101.

Obviously, $0 \leq x \leq 1$, and the probability of the event $0 \leq x \leq a$ is $a$ for any non-negative $a \leq 1$ (try to prove this rigorously).

It is easy to see that Grisha will win only if the sequence of tosses gives a number $x$ that is greater than

$$
0.10101010101 \ldots = 0 + \frac{1}{2} + \frac{0}{4} + \frac{1}{8} + \frac{0}{16} + \frac{1}{32} + \ldots = \frac{1}{2} \cdot \frac{1}{1 - 1/4} = \frac{2}{3}
$$

The probability of this is $\frac{1}{3}$. If the obtained fraction is less than $\frac{2}{3}$, Vanya wins. The event "exactly $\frac{2}{3}$" has a zero probability.

Another solution can be obtained by considering the first two tosses. Grisha wins only in the case of HH, and in the case of HT, no one wins, and the game starts again. Therefore, the probability of Grisha's win $p$ can be found from the equation

$$
p = \frac{1}{4} + \frac{1}{4} p, \text{ hence } p = \frac{1}{3}
$$

b) Let's call a successful toss one where the outcome is decided, i.e., heads on an even toss or tails on an odd toss. The probability of success on each individual toss is 0.5. Due to the independence of the tosses, the expected number of tosses is 2.

Answer: a) $1 / 3 ;$ b) 2.