Library · The Fiddler: Solutions · Chapter 153
Can You Escape the Infinite Loop?
Take a strip of paper inches long and inch wide, give it a single half twist, and join the two short edges to make a Möbius strip. Draw a dot on the midline of the strip, half an inch from both edges. Distance on the strip is measured as an ant crawls: the shortest path along the paper, which may pass over an edge onto the other face. Some point or points of the strip are as far as possible from the dot. How far?
The Fiddler, Zach Wissner-Gross, July 7, 2023(original post)
The official solution appeared in the post of July 14, 2023 and gives inches, attained at two points on the midline, and for the Extra Credit, with an average of faces. Both agree with the answers below.
Solution
The ant walks on the paper’s surface, so a spot on the front of the paper and the spot directly behind it on the back are different places, joined only by walking round an edge. The dot is drawn on the front.
Unrolling the surface. Shortest paths on a flat surface are straight lines once the surface is laid out flat, and this one can be laid out completely. Put the front face in the plane as the rectangle , , with the dot at the origin. An ant walking over the top edge carries straight on, now on the back, and the back is a mirror image of the front across that edge, so it can be laid down as the next rectangle up, . Walking over the bottom edge works the same way, and so on, band after band. Walking inches along the strip brings the ant back to where it started on the paper, but the half twist has put it on the other face; that copy can be laid down as the next rectangle along. The whole plane is tiled by rectangles, and moving one rectangle across or one up switches the face.
The figure shows the result. The shaded rectangles are copies of the back, the white ones copies of the front.
Where are the copies of the dot? A copy lies at for whole numbers and , provided the rectangle there is a front face, that is, provided is even. Moving one rectangle along also mirrors the strip top to bottom, but the dot sits on the midline, so its mirror image is itself. A path the ant crawls unrolls into a path in the plane of the same length, from the spot it ends at to one copy of the dot, and the shortest such path is straight. So the ant’s distance from the dot to a spot is the straight-line distance from the spot to the nearest copy of the dot.
The largest empty circle. So the question becomes: which point of the plane is farthest from its nearest black dot? Such a point is the centre of the largest circle that has no black dots inside it. Look at the three copies , and . The point on the -axis equidistant from all three is at with which simplifies to , so . This is the centre of the circle through , and , and its radius is . No other copy is closer to it: the next nearest are , at a distance , and , at .
To see that no point does better, notice that the plane is covered by triangles like and their mirror images, such as , , , all with corners at copies of the dot. Each triangle has all its angles below , so the centre of its circumcircle lies inside it. The lines from that centre to the midpoints of the three sides cut the triangle into six right triangles, each with corners at one dot, the midpoint of a side through that dot, and the centre. All three corners are within of that dot, and a disc contains every segment between its points, so the whole right triangle is too, with equality only at the centre. So every point of the plane is within of a copy of the dot. There are two of them. The centre is on the front, on the midline inches along the strip; the centre of the mirror triangle, at , is on the back, on the midline, inches the other way.
Three nearby guesses are each slightly wrong, which is what makes this puzzle treacherous. The point on the midline exactly halfway round is only inches away. The two points on the edge halfway round are inches away, since an ant can reach them along a straight line on the front. And on an untwisted ring the point opposite the dot on the inside would be inches away, but the twist opens a second, shorter route to it.
The computation
The check does not unroll anything. It covers both faces of the paper with a grid of spacing inch and lets the ant take short straight steps, with three rules for what happens when a step runs off the paper: over a long edge it lands on the other face, reflected; across the joined ends it lands on the other face with the strip turned over. Dijkstra’s shortest-path algorithm then finds the ant’s distance to every grid point. The steps run in directions, enough to follow straight lines closely, and they reproduce the paths in the figure exactly because .
import heapq
from math import gcd, hypot
# The strip is 10 by 1 in paper coordinates (x, y), with two
# faces, f = 0 (front) and f = 1 (back), on a grid of spacing
# 1/40. A step is a short straight move (di, dj) in grid units;
# land() says where it ends when it runs off the paper.
n = 40
X, Y = 10*n, n # x in 0..X-1 (wraps), y in 0..Y
def land(i, j, f, di, dj):
i, j = i + di, j + dj
if j < 0: # over the edge y = 0
j, f = -j, 1 - f
elif j > Y: # over the edge y = 1
j, f = 2*Y - j, 1 - f
if i >= X or i < 0: # across the join: the half twist
i, j, f = i % X, Y - j, 1 - f # flips y and face
return i, j, f
steps = [(a, b) for a in range(-6, 7) for b in range(-6, 7)
if (a, b) != (0, 0) and gcd(abs(a), abs(b)) == 1]
start = (0, Y//2, 0) # the dot: midline, front face
dist = {start: 0.0}
heap = [(0.0, start)]
while heap:
d, (i, j, f) = heapq.heappop(heap)
if d > dist[(i, j, f)]:
continue
for a, b in steps:
nxt = land(i, j, f, a, b)
nd = d + hypot(a, b)/n
if nd < dist.get(nxt, float("inf")):
dist[nxt] = nd
heapq.heappush(heap, (nd, nxt))
top = max(dist.values())
for (i, j, f), d in sorted(dist.items()):
if d > top - 1e-9:
print(f"farthest: x = {i/n:.3f}, y = {j/n:.3f}, "
f"face {f}, distance {d:.4f}")
It prints
farthest: x = 4.950, y = 0.500, face 1, distance 5.0500
farthest: x = 5.050, y = 0.500, face 0, distance 5.0500
These are the two points found above: on the front inches along, and on the back at , which is inches back the other way.
Extra Credit
Now take a prism whose ends are regular -gons, twist it by a random whole number of ths of a turn (from one up to , all equally likely), bend it into a loop and join the ends. For a square prism the twists of one, two, three and four quarters give , , and distinct faces, an average of . For which is the average number of distinct faces largest?
Solution
Number the prism’s side faces around the prism. Joining the ends with a twist of steps glues the end of face to the start of face , counting modulo . Following a single face round the loop over and over, you pass through faces , , , and so on, and all of these are one face of the finished solid. Face is reached from face exactly when is a multiple of modulo , and the multiples of modulo are exactly the multiples of . So the faces fall into classes, and the twisted prism has distinct faces. The square prism’s are .
The average over the twists is It has a tidy form. For each divisor of , the values of with are times the numbers from to that share no factor with , and there are of those, where is Euler’s totient function. So writing . The last sum is multiplicative: it splits into a product over the prime powers in . For a prime power, the divisors are and each with equals , so where means is the exact power of dividing .
Each prime contributes a factor between and for its first power, and each further power adds less than to that factor while multiplying the cost by . So the winners are numbers built from many small primes, with small exponents. The search over (below) settles it: the best is , with The runners-up are well behind: averages and averages . Adding the prime to multiplies the average by , almost doubling it, which no alternative within can match.
The computation
The check glues the faces directly. For each twist it joins face to face with a union–find structure and counts the classes, confirms the square prism’s , and confirms that the count equals for every twist of every prism up to . It then averages the face counts for every up to and lists the three best.
from fractions import Fraction
def distinct_faces(N, k):
"""Join an N-gon prism's ends with a twist of k/N of a
turn and count the faces. Once round the loop, side face
i runs on into side face i + k (mod N)."""
parent = list(range(N))
def root(a):
while parent[a] != a:
a = parent[a]
return a
for i in range(N):
parent[root(i)] = root((i + k) % N)
return len({root(i) for i in range(N)})
square = [distinct_faces(4, k) for k in (1, 2, 3, 4)]
assert square == [1, 2, 1, 4]
assert all(distinct_faces(N, k) == gcd(k, N)
for N in range(1, 61) for k in range(1, N + 1))
print("faces = gcd(k, N) for every prism up to N = 60")
avg = {N: Fraction(sum(gcd(k, N) for k in range(1, N + 1)), N)
for N in range(1, 1001)}
for N in sorted(avg, key=avg.get, reverse=True)[:3]:
print(f"N = {N}: average {avg[N]} = {float(avg[N]):.4f}")
It prints
faces = gcd(k, N) for every prism up to N = 60
N = 840: average 195/14 = 13.9286
N = 720: average 63/5 = 12.6000
N = 900: average 182/15 = 12.1333