Books · The Fiddler: Solutions
Chapter 35
When Will You Cross Your Path?
Anita the ant walks inch in a straight line, rotates counterclockwise by an angle , walks inches, rotates by again, walks inches, and so on. At some point her path crosses back over her very first -inch segment. Given that is the smallest angle for which this ever happens, how long was the segment along which she first crossed the initial segment?
The Fiddler, Zach Wissner-Gross, October 3, 2025(original post)
Solution
Place the start at the origin with the first segment along the positive -axis, so segment is and the vertices are For small the spiral opens outward and never returns. As grows, the first segment able to swing back onto the initial one is the fourth. At the smallest such the crossing is marginal: segment meets the initial segment exactly at its far endpoint . The line of segment passes through when , which telescopes to so . At that angle the crossing happens along the fourth segment, of length .
The computation
Walk the actual spiral: build the vertices, and for a sweep of angles find the first segment that crosses the interior of the initial unit segment. The smallest crossing angle is , and the crossing segment is the fourth.
import numpy as np
from math import cos, sin, acos, pi, degrees
def verts(phi, K):
P = [(0., 0.), (1., 0.)]
for k in range(2, K + 1):
h = (k - 1)*phi; P.append((P[-1][0] + k*cos(h), P[-1][1] + k*sin(h)))
return P
def crosses(A, B, eps=1e-9): # interior crossing of {y=0, 0<x<1}?
(x1, y1), (x2, y2) = A, B
if y1 == y2: return False
t = -y1 / (y2 - y1)
return eps < t < 1 - eps and eps < x1 + t*(x2 - x1) < 1 - eps
for phi in np.linspace(.001, pi - .001, 60000): # smallest crossing angle
P = verts(phi, 16)
hit = next((k for k in range(2, 16) if crosses(P[k-1], P[k])), None)
if hit: print(round(degrees(phi), 3), "deg, seg", hit); break # 138.593, 4
Extra Credit
What was the measure of the angle ?
Solution
From the marginal condition , (The exact angle is paywalled at the source; this closed form is my own.)
The computation
Pin the angle by bisection: shrink the bracket to the smallest at which the fourth segment just crosses the initial one. It converges to .
def seg4_crosses(phi):
P = verts(phi, 4); return crosses(P[3], P[4])
lo, hi = 2.0, 3.0
for _ in range(80):
mid = (lo + hi) / 2
lo, hi = (lo, mid) if seg4_crosses(mid) else (mid, hi)
print(round(degrees(hi), 3), round(degrees(acos(-0.75)), 3)) # 138.59 138.59