Prove it – Ep1: A Chance Encounter

Let’s follow an algorithm:

  1. Determine heuristic used in example.
  2. Summarize math solution.
  3. Define new heuristic, if possible.
  4. Discuss Claude’s math solution.
  5. Provide dashboard solution, if possible.

Claude prompt:
You and a friend live N blocks away from each other on a square grid. You both decide to take random walks towards each other. You flip coins at the same time and each go left or right depending on result. What are the chances you run into each other? Write a streamlit dash to illustrate.

Heuristic:

The extreme corners of the grid are unlikely to be reached, since they require all heads or tails. Discounting this, perhaps 1/3 is a good guess?

Mathematical solution:

Probability expansion. Calculate the probability of meeting at each location and then sum the total. Expand example to N:
n x n: P(you and your friend meet) (n even!)

 \frac{1}{2^{2n}} \sum_{i=0}^{n} \binom{n}{i}^{2}

New heuristic

N=2 is a coin flip. N=3 is 2^3 = 8 total outcomes. Since there are 3 meeting places, 3/8 = 0.375. Just over 1/3.

Maybe there is an underlying 1/N relationship? for N = 5, that means 20%. But, let’s adjust it upwards since 3/8 < 1/3.

25% estimate.

Claude math

Claude fails!!

Claude incorrectly assumes an exact 1/N relationship.

Dashboard

Here we can see the results for N=5. ~28%

Click the button to run it yourself!

Code

Efehn’s puzzles completely changed how I think—so engaging and rewarding!

Sarah Lee

Puzzle Enthusiast – Not a real person