Chapter 156
Lowest Unique Number and the Factor Chain
The Riddler for July 28, 2017. The Express, “submit the lowest unique positive integer,” is a participatory contest with no derivable optimum: the answer is whichever number from the reader pool happens to clear, with the winning value depending on the full empirical distribution. We defer it for the same reason as the Battle for Riddler Nation rounds and the Caffeine King. The Classic asks for the longest possible chain of distinct integers from to in which each consecutive pair shares the factor-multiple relation. We construct an explicit chain of length and verify it; longer chains remain open.
Riddler Express
Submit a positive integer. Whoever submits the lowest unique number among all submissions wins.
The Riddler, FiveThirtyEight, July 28, 2017(original post)
Deferred (participatory contest)
This Express has no derivable optimum from the puzzle statement. The winning number depends entirely on the empirical histogram of other readers’ submissions, which the puzzle hides until after the contest closes. There is no Nash equilibrium in pure strategies (any pure choice is beaten by a submission of , all the way down to a single submitter of , which itself is beaten by being non-unique). There is a mixed-strategy equilibrium in the large- limit (a heavy-tailed distribution with support on the small positive integers), but the precise mixture depends on and is not robust to the population of actual submitters. In practice, the announced winner was , chosen because it was “high enough that it would not be too popular” and “ended in a , which other submitters might think to avoid” (the reasoning quoted in the official write-up). submissions; no formula reproduces .
We defer this puzzle on the same grounds as the February , Battle for Riddler Nation Round , the May , Round , and the June , Caffeine King: the resolution is empirical, not mathematical. This is the sixth deferral in the build (after the four already in - and the Caffeine King in batch ).
Riddler Classic
You start with the integers from to inclusive and want to organise them into a chain. The only rules: each integer is used at most once, and each consecutive pair in the chain must satisfy “ is a factor or multiple of ”. What is the longest chain you can build? Extra credit: to .
The Riddler, FiveThirtyEight, July 28, 2017(original post)
Solution
Think of the integers to as vertices of a graph, with an edge between whenever or . The puzzle asks for the longest simple path in this graph (a path visiting distinct vertices), known as the longest-path problem and NP-hard in general. There is no closed-form formula nor any clever pencil-and-paper invariant; one has to search.
Structural observations. Several integers in are particularly hard to fit into a chain.
Primes in the range : each such prime has exactly two neighbours in the graph, namely and itself, so it can only sit at a chain endpoint preceded (or followed) by . There are such primes: . At most one of them can appear, since each demands as a neighbour and has only two neighbour slots in any chain.
Primes : are connected only to and their double in range. The double must be the other neighbour. These vertices form four pendant chains of length off the rest of the graph.
Vertex connects to every integer, so it sits in the middle of the chain in optimal constructions, used to bridge two “hub-like” clumps.
These constraints force at least of the “large primes” to be omitted from any chain. Together with several other awkward vertices (large primes like and that cannot be reached without burning ), a substantial fraction of integers cannot fit a maximum chain.
The construction. The longest chain found by exhaustive search through specialised solvers is integers. James Medhurst’s solution (the official winner) is Every consecutive pair satisfies the factor-multiple relation, and all integers are distinct. The bound of is reported as optimal by Anders Kaseorg’s clingo (answer-set programming) solver, though no closed-form proof of optimality is known to us; the value is conjectural until an independent exhaustive verification.
Extra credit ( to ). Kaseorg reports a chain of length but does not claim it is optimal. We have no improvement to offer for the larger version.
The computation
Encode the problem as graph-validity check on the published -chain, then run a heuristic search to confirm is a hard upper bound for naive approaches.
Build the adjacency: vertex is adjacent to iff and or .
Validate the published -chain: all distinct, all in , every consecutive pair adjacent.
Run a greedy heuristic (prefer the neighbour with fewest unused neighbours) from many random starts as evidence that is not reachable without sophisticated search.
import random
N = 100
ADJ = {k: set() for k in range(1, N + 1)}
for a in range(1, N + 1):
for b in range(1, N + 1):
if a != b and (a % b == 0 or b % a == 0):
ADJ[a].add(b)
medhurst = [
93, 31, 62, 1, 87, 29, 58, 2, 92, 46, 23, 69, 3, 57, 19, 38, 76, 4,
68, 34, 17, 85, 5, 35, 70, 10, 100, 50, 25, 75, 15, 45, 90, 30, 60,
20, 40, 80, 16, 64, 32, 96, 48, 24, 12, 6, 78, 26, 52, 13, 91, 7,
49, 98, 14, 56, 28, 84, 42, 21, 63, 9, 81, 27, 54, 18, 36, 72, 8,
88, 44, 22, 66, 33, 99, 11, 55,
]
def valid_chain(chain):
if len(set(chain)) != len(chain): return False
if any(not (1 <= x <= N) for x in chain): return False
return all(b in ADJ[a] for a, b in zip(chain, chain[1:]))
print(f"published chain length = {len(medhurst)}")
print(f"published chain valid? {valid_chain(medhurst)}")
def greedy(start, rng):
chain = [start]; used = {start}
while True:
opts = [x for x in ADJ[chain[-1]] if x not in used]
if not opts: break
opts.sort(key=lambda x: sum(1 for y in ADJ[x] if y not in used))
chain.append(opts[0]); used.add(opts[0])
return chain
rng = random.Random(0)
greedy_best = 0
for _ in range(20_000):
g = greedy(rng.randint(1, N), rng)
if len(g) > greedy_best:
greedy_best = len(g)
print(f"greedy best (20,000 random starts) = {greedy_best}")
# published chain length = 77
# published chain valid? True
# greedy best (20,000 random starts) = 59
The published chain validates; naive greedy reaches only , illustrating that the longest-path problem is genuinely hard on this graph and the -chain requires structured search.