Here's a math riddle inspired by a trading strategy.

**Random Walk (3 steps)**

- Imagine a person is standing at the middle of a long staircase. Call their position zero.

- They are going to move either up or down one step at a time.

- They will take 3 steps. The direction of each step is random.

*What is the probability the person crosses back through where they started (ie cross through zero)?*

#### Solution

This is a binomial problem where n = 3

The total number of paths = = 8

With only 8 paths we can write them out:

**25%**of the paths back thru zero.

Pretty straightforward. One handy thing to note is the problem is symmetrical whether the first step is up or down so could have just focused on either the up moves or just the down moves and gotten to the same answer.

25%

**Random Walk (5 steps)**

- Same question but now the person takes 5 steps, each in a random direction

*What is the probability the person crosses back through where they started (ie cross through zero)?*

#### Solution

n = 5

The total number of paths = = 32

We know from the earlier problem's symmetry that we can focus on just the 16 paths where the first step is "up".

You can probably sense the issue that’s emerging as the steps increase —> writing all the paths! With only 5 steps, it’s tedious to write out the 16 paths we will examine.

But it’s doable.

Yet we know it won’t be for long if the steps increase in later questions.

I asked ChatGPT how it would generate the paths and it gave me a clever answer:

The binary representation of each number is a distinct path!

(If you need a refresher on binary notation see

*Teach A Kid Binary and Other Non-base-10 Number Systems**)*Here’s some quick way to get the binary representation of a number currently denoted in base-10 (ie the numbers you are used to seeing)

- Copy and paste from the internet: https://www.javatpoint.com/binary-numbers-list

- The decimal to binary function in Excel —> DEC2BIN(number, places)
[
*warning: Excel can only convert a number into 10 bits which means the largest number you can represent is 512*]

This is all good news. We can show all 16 paths without needing to figure them out manually.

But we still need to count how many paths cross zero.

- Looking at path# 16, it’s clear it passes through 0. You moved up one step and then took 4 consecutive steps down.

- Eyeballing we can see that steps #16-20 and #24 all cross zero.

So 6

**/16**or**37.5%**of the time the random walk crosses through zero.However, just as the binary representation saved us the need to generate each path manually, is there a way to see if the path crosses zero without needing to eyeball each route? Eyeballing isn’t going to work as steps increase.

If you like coming up with Excel formulas, then this will scratch the same itch.

**The “did we cross zero?” logic**

This is the answer combining:

- our binary representation for the path and

- the logic for whether we crossed zero

*By the 2nd step if you had at least 1 up move you haven't crossed zero*

*By the 3rd step if you had at least 1.5 up moves you haven't crossed zero*

*By the 4th step if you had at least 2 up moves you haven't crossed zero*

*By the 5th step if you had at least 2.5 up moves you haven't crossed zero*

**Random Walk (11 steps)**

- Same question but now the person takes 11 steps, each in a random direction

*What is the probability the person crosses back through where they started (ie cross through zero)?*

This is your chance to put it altogether.

#### Solution

n =11

The total number of paths = 2¹¹= 2048

Because of symmetry, I just tabulated paths numbered 1024 to 2047 (inclusive) for a total of 1024 paths.

**562/1024**or

**54.9%**of paths crossed zero

This is a snippet of the solution table with paths represented in binary and the logic of “did we cross zero”