Solution (source code)

= Solution

Shift the absorbing interval to $\{0,\ldots,a+1\}$ and start at $1$. The gambler’s-ruin harmonic <functions> give $\mathbb P(\tau_a\lt \tau_{-1})=1/(a+1)$ and $\mathbb ET=1(a+1-1)=a$.