Coin Walk

You are in an open field with two coins and you alternate flipping the coins and taking steps by the following rules:

If both coins are heads, then you take one step north.

If both coins are tails, then you take one step south.

If the first coin is heads and the second coin is tails, then you take one step west.

If the first coin is tails and the second coin is heads, then you take one step east.

Assuming that nothing is in your way and that the two coins are fair coins, then the probability that after 20 20 steps you are back to where you started is p q \frac{p}{q} where p p and q q are relatively prime integers. Find p + q p + q .


The answer is 70852900457.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Rowan Hess
Jan 9, 2020

Because to move North/West the first flip must be heads and to move South/East it must be tails, there has to be an equal number of heads flipped on the first flip as tails. This gives ( 10 20 ) (^{20}_{10}) ways to flip the first coin and get back to where you started.

Likewise, to move North/East, the second flip must be heads, and to move South/West, it must be tails. This means there are ( 10 20 ) (^{20}_{10}) ways to flip the second coin and end up back where you started.

Because there are 4 20 4^{20} ways to perform all of the flips, the probability of returning to the start becomes ( 10 20 ) 2 4 20 = 2133423721 68719476736 \frac{(^{20}_{10})^2}{4^{20}} = \frac{2133423721}{68719476736}

so the answer is 70852900457 70852900457 .

Mark Hennings
Nov 20, 2019

Moving in each of the cardinal directions is equally likely. To return to the starting position after 20 20 steps, you need to have taken an equal number ( n n each, say) of East and West steps and an equal number ( 10 n 10-n each) of North and South steps. Thus the probability of getting back to the start is 1 4 20 n = 0 10 20 ! n ! × n ! × ( 10 n ) ! × ( 10 n ) ! = 2133423721 68719476736 \frac{1}{4^{20}}\sum_{n=0}^{10} \frac{20!}{n! \times n! \times (10-n)! \times (10-n)!} \; = \; \frac{2133423721}{68719476736} making the answer 2133423721 + 68719476736 = 70852900457 2133423721 + 68719476736 = \boxed{70852900457} .

In the 2 N 2N step case, this sum (the probability of returning home) turns out to be P ( 2 N ) = ( 1 4 N ( 2 N N ) ) 2 P(2N)=\left( \frac{1}{4^N} \binom{2N}{N} \right)^2 .

Using Stirling's approximation for the binomial coefficient, for large N N this becomes the rather surprising P ( 2 N ) 1 π N P(2N) \approx \frac{1}{\pi N} . Because we're dealing with squares of factorials, "large" doesn't even mean all that large - for example, in this case ( N = 10 N=10 ), the exact probability is 0.031045 0.031045\ldots whereas we have 1 10 π = 0.031830 \frac{1}{10\pi}=0.031830\ldots , a relative error of just 2.5 % 2.5\% .

So, this gives a way to calculate π \pi - maybe not the most efficient, though. You could even combine it with getting to know a new city, as long as its streets form a grid.

Chris Lewis - 1 year, 6 months ago

Log in to reply

That's a pretty neat way to calculate pi that I did not know about before!

David Vreken - 1 year, 6 months ago

Another point of interest is that ( 2 N N ) 2N \choose N are the center numbers of Pascal's Triangle.

David Vreken - 1 year, 6 months ago

Just to add to Chris Lewis's comment, one way to see that P ( 2 N ) = 1 4 2 N ( 2 N N ) 2 P(2N) = \frac1{4^{2N}} \binom{2N}{N}^2 is to realize that the first coin must come up heads exactly N N out of 2 N 2N times, and the second coin must come up heads exactly N N out of 2 N 2N times.

Patrick Corn - 1 year, 6 months ago

Log in to reply

That's a nice way of looking at it - makes me think that may have been the intention behind the problem.

Chris Lewis - 1 year, 6 months ago
David Vreken
Nov 23, 2019

To get back to where you started, you must have an equal amount of north steps and south steps, and an equal amount of west steps and east steps. If there are 2 n 2n steps, then you could have n n north, n n south, 0 0 west, and 0 0 east steps in any order for a total of ( 2 n ) ! n ! n ! 0 ! 0 ! \frac{(2n)!}{n!n!0!0!} different ways, or you could have n 1 n - 1 north, n 1 n - 1 south, 1 1 west, and 1 1 east steps in any order for a total of ( 2 n ) ! ( n 1 ) ! ( n 1 ) ! 1 ! 1 ! \frac{(2n)!}{(n - 1)!(n - 1)!1!1!} different ways, and so on, until 0 0 north, 0 0 south, n n west, and n n east steps in any order for a total of ( 2 n ) ! 0 ! 0 ! n ! n ! \frac{(2n)!}{0!0!n!n!} different ways. In summary:

W = k = 0 n ( 2 n ) ! ( ( n k ) ! ) 2 ( k ! ) 2 W = \sum_{k=0}^{n} \frac{(2n)!}{((n - k)!)^2(k!)^2}

which can be shown inductively to be equal to

W = ( ( 2 n ) ! n ! n ! ) 2 W = \bigg(\frac{(2n)!}{n!n!}\bigg)^2

For 20 20 steps, there are ( ( 2 10 ) ! 10 ! 10 ! ) 2 = 34134779536 \bigg(\frac{(2 \cdot 10)!}{10!10!}\bigg)^2 = 34134779536 ways to get back to where you have started out of a total of 4 20 = 1099511627776 4^{20} = 1099511627776 ways , for a probability of 2133423721 68719476736 \frac{2133423721}{68719476736} . Therefore, p = 2133423721 p = 2133423721 , q = 68719476736 q = 68719476736 , and p + q = 70852900457 p + q = \boxed{70852900457} .

In the calculation for 34134779536 34134779536 , all the 20 20 s should be 10 10 s. (The total number of steps is represented by 2 n 2n , not n n .)

Matthew Feig - 1 year, 5 months ago

Log in to reply

Thanks! I edited it.

David Vreken - 1 year, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...