Skip to content
Vamshi Jandhyala

Books · The Fiddler: Solutions

Chapter 8

Can You Hop Around the Chessboard?

A frog is hopping around a chessboard, always from the centre of one square to the centre of another. Each square has side length 11, but the board is NN-by-NN for some large whole number NN. Every jump the frog makes must be the same distance LL. The frog wants to make four jumps such that: after the fourth jump it has returned to its starting square; it visits four distinct squares along the way, counting the starting square; the path is not a square loop; and the frog is never on a square that is a bishop’s move or a rook’s move away from its starting square. What is the smallest jumping distance LL for which this is possible?

The Fiddler, Zach Wissner-Gross, May 1, 2026(original post)

Solution

Place the starting square at the origin, so every square centre is a lattice point. Each jump is a vector (a,b)(a,b) with a2+b2=L2a^2+b^2=L^2, and the four jumps must sum to zero. A four-jump closed loop through four distinct squares needs at least two genuinely different jump vectors of the same length; the simplest shape is a parallelogram u,w,u,wu, w, -u, -w. The constraints act on the visited squares uu, u+wu+w, ww: none may have a zero coordinate (no rook move), none may have x=y|x|=|y| (no bishop move), and the loop must not be a square.

Two different lattice vectors of equal length exist when L2L^2 is a sum of two squares in two essentially different ways. The smallest candidates 2525 and 5050 are killed by zero or equal coordinates; the next is 65=12+82=42+72.65 = 1^2 + 8^2 = 4^2 + 7^2 . Taking u=(8,1)u=(8,1), w=(7,4)w=(7,4), the visited squares (8,1),(15,5),(7,4)(8,1),(15,5),(7,4) satisfy every condition, and an exhaustive search confirms nothing smaller works: L=658.0623.L = \boxed{\sqrt{65}} \approx 8.0623 .

The computation

Search every squared length L2L^2 in order: list all lattice jump vectors of that length and try every triple of jumps (the fourth is forced by closure). Keep a loop only if it visits four distinct squares, none a rook or bishop move from the origin, and is not a square. The first length that admits one is 6565.

import itertools
def ok(p):  # not a rook/bishop move from the origin
    dx, dy = p
    return dx != 0 and dy != 0 and abs(dx) != abs(dy)
for L2 in range(1, 200):
    R = range(-15, 16)
    vecs = [(a, b) for a in R for b in R if a*a + b*b == L2]
    hit = False
    for u, w, z in itertools.product(vecs, repeat=3):
        p2 = (u[0]+w[0], u[1]+w[1]); p3 = (p2[0]+z[0], p2[1]+z[1])
        if p3[0]**2 + p3[1]**2 != L2: continue       # closing jump length L
        pts = [u, p2, p3]
        if len({(0, 0), *pts}) != 4 or not all(ok(p) for p in pts): continue
        sides = [u, w, z, (-p3[0], -p3[1])]
        if all(s[0]*t[0] + s[1]*t[1] == 0 for s, t in zip(sides, sides[1:])):
            continue  # square loop
        hit = True; break
    if hit:
        print(L2); break                             # 65

Extra Credit

The frog now jumps with that same minimum distance L=65L=\sqrt{65}, and wants to be able to reach every square of the board. What is the minimum NN for which this is possible?

Solution

The available jumps are the sixteen vectors (±1,±8)(\pm 1,\pm 8), (±8,±1)(\pm 8,\pm 1), (±4,±7)(\pm 4,\pm 7), (±7,±4)(\pm 7,\pm 4). On a small board almost all of them leave the board, and the reachable set is a proper subset. As NN grows the reachability graph knits together: for N=13N=13 it is still disconnected, while for N=14N=14 every square reaches every other. The minimum board size is N=14.\boxed{N = 14}.

The computation

For each board size, breadth-first search the reachability graph from one corner, following only jumps that stay on the board, and check whether all N2N^2 squares are reached. The first fully connected size is 1414.

from collections import deque
R = range(-9, 10)
jumps = [(a, b) for a in R for b in R if a*a + b*b == 65]
def connected(N):
    seen = {(0, 0)}; dq = deque(seen)
    while dq:
        x, y = dq.popleft()
        for dx, dy in jumps:
            p = (x+dx, y+dy)
            if 0 <= p[0] < N and 0 <= p[1] < N and p not in seen:
                seen.add(p); dq.append(p)
    return len(seen) == N*N
print(next(N for N in range(8, 20) if connected(N)))  # 14