Solution (source code)

= Solution

The <expected value> of an <indicator random variable> is the <probability> of its <event>. For a <simple symmetric random walk> absorbed at $0,k$, the <gambler's ruin> success <probability> from $i$ is $i/k$. Hence
$$
\boxed{\mathbb E_i[J]=\frac ik.}
$$
The boundary values are $0$ at the left exit and $1$ at chamber $k$.