Skip to content
Vamshi Jandhyala

Mathematics

The Ladybug's Last Number

PDF

A MoMath Mindbender suggested by Richard Stanley: a ladybug starts on the 12 of a clock face and steps to a random neighbour at each strike until she has visited every number. The last new number is the 6 with probability 1/11, because on a cycle every vertex other than the start is equally likely to be last, and the 6 sitting opposite the 12 counts for nothing.

Problem

A ladybug alights on the 12 of a cuckoo clock. Whenever the clock strikes, she moves randomly to a neighbouring number, so the first time, she moves to the 1 or the 11 with equal probability. Suppose the ladybug continues this process until she has been to all of the numbers at least once. What is the probability that the last new number she visits is 6?

Credit: Peter Winkler, Monthly Mindbenders, National Museum of Mathematics, January 2026, problem suggested by Richard Stanley.

Setting it up

Label the numbers 0,1,,110, 1, \dots, 11, writing 00 for the 12 and reading all arithmetic modulo 1212. The clock face is then the cycle C12C_{12}, and the ladybug performs a simple random walk on it from 00. Everything below works on CnC_n for any n3n \ge 3: the clock is the case n=12n = 12, and the 6 is the vertex v=6v = 6.

Two panels on a cream background. Left: the twelve numbers of a clock face drawn as circular nodes joined into a ring, with 12 at the top filled in copper and labelled start, and 6 at the bottom filled in green and labelled 'the 6, no more special than any other number'. One covering walk is traced faintly along the ring itself, so the arcs the ladybug crossed most often show darkest, and the centre reads 'one covering walk (148 strikes)'. Right: a bar chart of the simulated probability that each number is the last new one visited, over 200,000 covering walks. The bar for 12 is at zero and marked 'start: never last'; the eleven bars for 1 to 11 all sit level at just over 0.09 against a dashed copper line at 1 over 11, about 0.0909, with the bar for 6 picked out in green at 0.0903.
Left: the clock face is a $12$-cycle, with one covering walk traced faintly along the edges it used. Right: the simulated chance that each number is the last new one visited. The eleven bars sit level on $1/11$, and the 6 is one of the eleven.

What has been seen is always a block

At every moment the set of numbers already visited is a block of consecutive numbers containing the start. This holds at the outset, when the set is {0}\{0\}. Suppose it holds now. The ladybug stands somewhere in the block, and her next step lands on a neighbour: either on a number already in the block, which changes nothing, or on a fresh number, which can only happen when she is standing at one end of the block and steps outward, extending it by one. Either way the visited set is again a block. Induction does the rest.

To be last is to be surrounded

Fix a target v0v \ne 0 with neighbours a=v+1a = v+1 and b=v1b = v-1. Then v is the last new number    the walk visits both a and b before it visits v.v \text{ is the last new number} \iff \text{the walk visits both } a \text{ and } b \text{ before it visits } v.

One direction is immediate: if vv is last then in particular aa and bb came earlier. For the other, suppose aa and bb have both been visited while vv has not. At that moment the visited set is a block containing 00, aa and bb but avoiding vv, so it sits inside the arc running from aa round to bb the long way, which is exactly the complement of {v}\{v\}. A block of consecutive numbers that lies in that arc and contains both of its ends is the whole arc. So every number except vv has been visited, and vv is last.

Cutting the cycle at the target

The only ways into vv are through aa and bb. Until the moment she first steps onto vv, therefore, the ladybug is walking on the path obtained by deleting vv from the cycle, a=v+1, v+2, , 0, , v1=b,a = v+1, \ v+2, \ \dots, \ 0, \ \dots, \ v-1 = b, which has n1n-1 vertices. Number its positions 0,1,,m0, 1, \dots, m with m=n2m = n-2, so that position 00 is aa and position mm is bb. This path is not reflecting at its ends: from aa or bb the ladybug steps onto vv with probability 12\tfrac12, and that ends the question.

Let TT be the first time she stands on aa or on bb. She cannot have visited vv by time TT, since reaching vv requires standing on an end first. (If vv happens to neighbour the start, then the start is itself an end and T=0T = 0.) So at time TT she is at one end of the path, vv is untouched, and the surviving question is whether she reaches the far end before slipping into vv.

Suppose she is at bb; the case of aa is the mirror image. Write q=P(reach a before vstanding at b, with v unvisited).q = \mathbb{P}(\text{reach } a \text{ before } v \mid \text{standing at } b, \text{ with } v \text{ unvisited}). The next strike sends her to vv with probability 12\tfrac12, which fails, and inward to position m1m-1 with probability 12\tfrac12. From position m1m-1 the walk is an ordinary gambler’s ruin on {0,1,,m}\{0, 1, \dots, m\}: starting at kk, the chance of reaching 00 before mm is (mk)/m(m-k)/m, so from k=m1k = m-1 she reaches aa first with probability 1/m1/m and returns to bb first with probability 11/m1 - 1/m. A return to bb leaves her exactly as she was, with vv still unvisited, so the same qq applies again. Hence q=12[1m+(11m)q],q = \frac12\left[\frac{1}{m} + \left(1 - \frac{1}{m}\right) q\right], and rearranging gives q(1+1m)=1mq\left(1 + \tfrac1m\right) = \tfrac1m, that is, q=1m+1=1n1.q = \frac{1}{m+1} = \frac{1}{n-1}.

The same value comes out of the mirrored case. Since the two cases exhaust the possibilities at time TT, P(v is last)=P(at b at time T)1n1+P(at a at time T)1n1=1n1.\mathbb{P}(v \text{ is last}) = \mathbb{P}(\text{at } b \text{ at time } T)\cdot\frac{1}{n-1} + \mathbb{P}(\text{at } a \text{ at time } T)\cdot\frac{1}{n-1} = \frac{1}{n-1}.

Nothing about vv survived the calculation. On C12C_{12}, with the ladybug starting at the 12, P(the last new number is 6)=1110.0909.\mathbb{P}(\text{the last new number is } 6) = \frac{1}{11} \approx 0.0909.

Why the position of the 6 does not matter

The general statement is worth recording, since the clock is only an instance of it.

Proposition. Let a simple random walk on the cycle CnC_n start at a vertex ss and run until every vertex has been visited. Each of the other n1n-1 vertices is the last new vertex with probability 1/(n1)1/(n-1).

The eleven probabilities on the clock face add to 11, as they must, and the 12 is never last because it is where the ladybug began. A quick sanity check at the small end: on a triangle, the walk’s first step picks one of the two non-start vertices and the other is last, so each is last with probability 12=1/(31)\tfrac12 = 1/(3-1).

The surprise is that the distance from 12 to 6 plays no part, and the proof shows precisely where that distance goes. It decides which neighbour of the target the ladybug meets first, and nothing else: the race from that neighbour, the long way round to the other one and without falling into vv en route, is worth 1/(n1)1/(n-1) from either end.

There is a plainer way to feel it. A number next to the start, say the 1, has one of its neighbours visited for free at time zero, but the walk must then make its way almost the whole distance round the face to the 2, and every time it comes back to the 12 or arrives at the 2 it risks stepping onto the 1 and spoiling the attempt. A number opposite the start, like the 6, gets no free neighbour, but neither of its two neighbours is far away. Being distant helps a number get surrounded from the near side and hurts it on the far side, and the ruin calculation is the statement that the two effects cancel exactly, not approximately. That the 6 sits diametrically opposite the 12 is a red herring, and a good one.

QuantityValue
P(the last new number is 6)\mathbb{P}(\text{the last new number is } 6)1/110.09091/11 \approx 0.0909
P(the last new number is k)\mathbb{P}(\text{the last new number is } k), any k12k \ne 121/110.09091/11 \approx 0.0909
general cycle CnC_n, any vertex other than the start1/(n1)1/(n-1)

Computational verification

The argument is short enough to be suspicious, and its one delicate step, that a block of visited numbers containing both neighbours of vv must already be everything but vv, is exactly the sort of claim a simulation can embarrass. So the check throws the theory away: walk the clock face by the rules, stop on the strike that completes the set, and record which number that was. What matters in the output is not the single figure for the 6 but the flatness of the whole profile.

import numpy as np
rng = np.random.default_rng(20260116)
N, n, TARGET = 200_000, 12, 6

def last_new():                      # walk from the 12 until every number is seen
    pos, seen = 0, {0}
    while len(seen) < n:
        pos = (pos + 2*int(rng.integers(0, 2)) - 1) % n
        seen.add(pos)
    return pos                       # the number reached on the covering strike

counts = np.zeros(n, dtype=int)
for _ in range(N):
    counts[last_new()] += 1
p = counts / N

print(f"P(last = 6) = {p[TARGET]:.4f}      1/11 = {1/11:.4f}")
print("profile 1..11 = " + " ".join(f"{x:.4f}" for x in p[1:]))
print(f"widest gap across the eleven = {p[1:].max() - p[1:].min():.4f}")
# P(last = 6) = 0.0914      1/11 = 0.0909
# profile 1..11 = 0.0896 0.0919 0.0906 0.0912 0.0907 0.0914 0.0908 0.0910
#                 0.0903 0.0914 0.0913
# widest gap across the eleven = 0.0023

With 200,000200{,}000 walks the standard error on each entry is about 0.00060.0006, so a spread of 0.00230.0023 across eleven numbers is what a flat profile looks like from this distance. No number on the face is favoured, and the 6 least of all.