Solution (source code)

= Solution

In the positive-recurrent case, let $q=p_0+p_1<p$. Detailed balance for the length chain requires
$$
\pi_kq=\pi_{k+1}p,
$$
so, with $r=q/p<1$,
$$
\pi_k=\pi_0r^k.
$$
Normalization gives $\pi_0=1-r$. The self-loop at zero makes the length chain aperiodic, so the convergence theorem for irreducible positive-recurrent aperiodic Markov chains gives
$$
\boxed{
\lim_{n\to\infty}\mathbb P(\ell(X_n)=k\mid X_0=\varnothing)
=\left(1-\frac{p_0+p_1}{p}\right)
\left(\frac{p_0+p_1}{p}\right)^k
}.
$$