A puzzle on a square
I had cause to revisit an old @edsouthall tweet:
Random Walk Problem #1
— Ed Southall (@edsouthall) May 20, 2016
Tricky… pic.twitter.com/RfHA0ntSCg
It’s a nice puzzle. Try it yourself! Spoilers below the line.
As a clarification: the square drawn must have the starting point as its top left corner.
My approach
Given that you’re at one corner of the square, you always have two moves that will keep you on the square. The probability of every one of the eight moves remaining on the square is
Up to rotation/reflection, there are only six possible states we can be in (after we’ve made at least one move). I’m going to adopt a convention of a * showing where the dot is, and a - showing the edges drawn so far.
There’s one four-edge state (
There are two three-edge states: —* (
—* moves to the four-edge state and to –*- with equal probability; –*- stays put and moves to —* with equal probability.
There are two two-edge states: –* (
And there is one one-edge state: -* (
What I did was to meticulously catalogue where I could be after each move and spot that in 63 of the 128 possible cases, I ended up in state
Transition matrices
But hang on a second! Going from one state to another with specified probabilities… that’s how the googles work! I can write down a matrix of probabilities like this:
with
We start after one move in position
The probabilities of the states after seven further moves are given by
OEIS
Of course, I can also make use of the OEIS. My scrappy notes show that the number of paths ending in state
That turns out to be listed and has the explicit formula
Why this should be the case, I don’t know.
Ed’s follow-up
After seeing my answer, Ed noted that
Finishing up
As @ImMisterAl pointed out on Twitter, I didn’t actually answer the question asked: the probability of ending up with this pattern is
I’d welcome any other insights you might have!
* Edited 2021-01-25 to fix formatting and answer the question.