Random walking and the expected value I was asked this question at an interview, and I didn't know how to solve it. Was curious if anyone could help me.
Lets say we have a square, with vertex's 1234. I can randomly walk to each neighbouring vertex with equal probability. My goal is to start at '1', and get back to '1'. How many average walks will I take before I return back to 1?

If your numbers run around the square, positions $2$ and $4$ are equivalent.  Let $x$ be the average number of steps to return to $1$, $y$ be the average number of steps to get to $1$ from $2$, and $z$ to be the average number of steps to get to $1$ from $3$.  If you are at $3$, you must go to $2$, so $z=y+1$.  If you are at $2$, you go to $1$ with chance $\frac 12$, so $y=\frac 12+\frac12(1+z)$.  Similarly, $x=1+y$.  So $y=\frac 12 + \frac 12 (y+2)3$, or $y=3$ and $x=4$
