An ant walks the sticks from S to E
The frame is made of dots joined by sticks. The ant can only walk along sticks. We ask three questions, each harder than the last.
Why “never visiting a dot twice” in Q1? If the ant may go round in circles, it can loop forever and the number of walks is infinite. So the sensible question is about simple paths.
Every path is a word made of R and U
Each move is either R (one stick right) or U (one stick up). Write the moves down and the path becomes a word.
The key observation
So the length never changes. Only the order of R's and U's changes. Counting paths is the same as counting the different ways to arrange the letters of the word. That is a job for factorials.
Counting arrangements with n!
n factorial, written n!, is the product of all whole numbers from n down to 1. It counts the ways to put n different things in a row: n choices for the first place, n−1 for the second, and so on.
When letters repeat
The rule: arrangements of a word = (total letters)! ÷ (product of the factorials of each repeated letter). By convention 0! = 1, so a letter that appears zero times changes nothing.
Choose which moves are U
Picking a set of positions without caring about order is a combination. The number of ways to choose r things from n is
Count the ways to reach each dot
There is a second way to get the same answer, and it keeps working when the grid is damaged.
To arrive at a dot moving only up or right, the ant's last step came either from the left or from below. So:
Dots on the bottom edge and left edge can be reached in only 1 way. Press S to fill one diagonal at a time.
These numbers are Pascal's triangle turned on its side. Each one is a combination: the dot that is a steps right and b steps up shows ⁽ᵃ⁺ᵇ⁾C_b.
Subtract the paths that need the broken stick
Click any stick on the grid to break it (click again to mend). The broken stick is drawn in red.
Method 1: count the bad paths
Method 2: add along the grid
Run the fill. A broken stick simply passes on nothing, so the dot above or to the right of it gets fewer ways. This method works for any number of broken sticks.
When the ant may wander
Now the ant can go up, down, left or right, but it may never step on a dot it has already visited. Mathematicians call these self-avoiding paths.
Why no formula?
Up-and-right paths always have the same length, so we could count letter arrangements. A wandering path can be short or very long, and whether a move is allowed depends on everywhere the ant has already been. No one has found a closed formula. These numbers are found by computer, sweeping a line across the grid and keeping track of how the half-built path pieces connect.
| Square grid (dots) | Up & right | Any direction |
|---|
Look at the last column: it explodes far faster than the factorial-based column. That is why the reel's first question has such a large answer.