Let's group the dice results in threes: this way we will have eight possible outcomes, and each has a probability of $1 / 8$. The probability of not getting $F F F$ in $n$ such triples is $(7 / 8)^{n}$, since a triple has a $7 / 8$ probability of not being $F F F$, and the triples are independent. This probability is smaller than the probability that there is no $F F F$ in the first $3 n$ rolls, because now $F F F$ can also occur between the split triple blocks according to the previous grouping. Therefore, the probability that there is neither $F F F$ nor $F I F$ in the first $3 n$ rolls tends to 0, so the sequence of rolls will certainly end in a finite number of steps.

Let $A$ denote the event that FFF occurs before FIF, and let $I_{j}$ be the event that the $j$-th roll is tails, and $F_{j}$ the event that the $j$-th roll is heads. The events $I_{1}, F_{1} F_{2} F_{3}, F_{1} F_{2} I_{3}, F_{1} I_{2} F_{3}, F_{1} I_{2} I_{3}$ form a complete system of events (one and only one of them will occur), and the conditional probabilities of $A$ given that these events occur are as follows:

$P\left(A \mid I_{1}\right)=P(A)$, because after the first tails roll, the competition between $F F F$ and FIF restarts under unchanged conditions;

$P\left(A \mid F_{1} F_{2} F_{3}\right)=1$, because in this case FFF occurs first;

$P\left(A \mid F_{1} F_{2} I_{3}\right)=\frac{1}{2} \cdot P(A)$, because if $F_{1} F_{2} I_{3}$ is followed by $F_{4}$, then FIF occurs first, and only if $I_{4}$ comes, the competition between the $F F F, F I F$ blocks restarts;

$P\left(A \mid F_{1} I_{2} F_{3}\right)=0$, because in this case FIF occurs first;

$P\left(A \mid F_{1} I_{2} I_{3}\right)=P(A)$ just like in the case of $P\left(A \mid I_{1}\right)$.

According to the theorem of total probability, if we multiply these conditional probabilities by the probability of the condition and sum the results, we get $P(A)$:

$$
\frac{1}{2} \cdot P(A)+\frac{1}{8} \cdot 1+\frac{1}{8} \cdot \frac{1}{2} \cdot P(A)+\frac{1}{8} \cdot 0+\frac{1}{8} \cdot P(A)=P(A)
$$

which can only be satisfied by $P(A)=\frac{2}{5}$. Therefore, the probability that FFF comes before FIF is $\frac{2}{5}$.

András Lelkes

Remark. The result is surprising, as one might expect that the two events are interchangeable, and thus $P(A)=\frac{1}{2}$. The reason this is not the case is precisely that the two events are not equal, the block of three heads is harder to form than the FIF roll outcome.
A coin is flipped until either $F F F$ or $F I F$ appears in three consecutive flips (where $F$ represents heads and $I$ represents tails). What is the probability that $F F F$ appears before $F I F$?