Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 167

Four Puzzles From Riddler Nation’s Students

To mark the 100th Riddler column, FiveThirtyEight handed the puzzles over to maths students. Four puzzles were posed: a handshake-arrangement count, a where-does-the-extra-digit-go riddle, an optional-skip standardised test, and an image-based cornucopia grid. The cornucopia (Riddle 4) depends on an image-only chart of leaves, pumpkins, apples, candy corn, and acorns whose pixel-level values are not recoverable from the corpus; it is deferred, consistent with the rest of this volume’s image-blocked puzzles. The three derivable puzzles follow.

Riddle 1

Six knights sit at a round table and must complete a greeting ceremony: every member shakes hands with every other member exactly once. During each round of handshakes, every member must be shaking exactly one hand, and arms may not cross. Between rounds, the seating may be rearranged. What is the minimum number of seating arrangements needed for six knights? Eight knights? NN knights?

The Riddler, FiveThirtyEight, November 17, 2017(original post)

Solution

The answer is log2N\lceil \log_2 N\rceil arrangements, and NN must be even.

The non-crossing rule forces a bipartite cover. Each seating arrangement partitions the knights into two halves (those on the left of the table and those on the right). Within one arrangement, a single “round” of handshakes is a non-crossing perfect matching, but the problem allows many rounds in the same arrangement (no rearranging in between): we can keep handshaking until every left–right pair has shaken hands, since the chords between left and right knights can be enumerated in N/2N/2 successive non-crossing matchings (KN/2,N/2K_{N/2,N/2} has a 11-factorisation). So one arrangement covers exactly the pairs that span its two halves.

A cover of the complete graph KNK_N by complete bipartite subgraphs is what we need; the minimum number is the biclique cover number of KNK_N. The Graham–Pollak theorem says this number equals log2N\lceil \log_2 N\rceil.

The construction. Label the NN knights 0,1,,N10, 1, \dots, N - 1 and view labels in binary. For r=0,1,,log2N1r = 0, 1, \dots, \lceil \log_2 N\rceil - 1, the rrth arrangement seats knights with bit rr equal to 00 on the left and bit rr equal to 11 on the right. Every pair of distinct knights differs in at least one bit, so each pair sits left–right in at least one arrangement and shakes hands then.

The lower bound. Pick any knight, call her KK. In one arrangement KK shakes hands with everyone on the opposite side, namely N/2N/2 knights, so the count of knights she has not yet shaken with falls by at most a factor of two each arrangement (from N1N - 1 to (N1)/2\lceil (N-1)/2\rceil, etc.). She needs to reach 00, so the number of arrangements is at least log2N\lceil \log_2 N\rceil.

For N=6N = 6 and N=8N = 8: log26=log28=3\lceil \log_2 6\rceil = \lceil \log_2 8\rceil = 3.

The computation

For each N{2,4,6,8,10,12,14,16}N \in \{2, 4, 6, 8, 10, 12, 14, 16\} build the binary bipartition cover, enumerate every (left, right) pair within each arrangement, and check that every distinct {i,j}\{i, j\} has been covered.

  1. For each arrangement r=0,,log2N1r = 0, \dots, \lceil \log_2 N\rceil - 1, partition knights by bit rr of their label.

  2. Within one arrangement, every (left, right) pair shakes hands at some point.

  3. Aggregate across arrangements and confirm full pairwise coverage.

from math import ceil, log2

def covered_pairs(N):
    R = ceil(log2(N))
    pairs = set()
    for r in range(R):
        bit = 1 << r
        L = [j for j in range(N) if (j & bit) == 0]
        R_ = [j for j in range(N) if (j & bit) != 0]
        for a in L:
            for b in R_:
                pairs.add(frozenset((a, b)))
    return R, pairs

for N in (2, 4, 6, 8, 10, 12, 14, 16):
    R, pairs = covered_pairs(N)
    needed = N * (N - 1) // 2
    print(N, "rounds =", R, "covers", len(pairs), "of", needed,
          "ok =", len(pairs) == needed)

For every even NN in the sweep, the construction covers all (N2)\binom{N}{2} pairs using exactly log2N\lceil \log_2 N\rceil arrangements, matching the lower bound.

Riddle 2

In Kevin’s number system, the digit keleven (an integer that lies between two other single-digit integers) is inserted somewhere along the number line. Other than this insertion, all digits remain in the usual order. Two calculations found in Kevin’s notes: 853+520=1473,41×26=976.853 + 520 = 1473, \qquad 41 \times 26 = 976. Where does keleven belong?

The Riddler, FiveThirtyEight, November 17, 2017(original post)

Solution

There are 1111 single-digit symbols (the usual ten plus keleven), so Kevin’s system is base-1111. Inserting keleven KK between digit symbols dd and d+1d+1 (in the usual 0,1,,90, 1, \dots, 9 ordering) gives a digit ordering 0,1,,d, K, d+1,,9,0, 1, \dots, d,\ K,\ d+1, \dots, 9, and the symbol-to-value map is: symbols 0,1,,d0, 1, \dots, d keep their face values 0,,d0, \dots, d; the symbol KK has value d+1d + 1; the symbols d+1,d+2,,9d+1, d+2, \dots, 9 have values d+2,d+3,,10d+2, d+3, \dots, 10.

Test KK between 44 and 55. Then the symbol-to-value map is 56, 67, 78, 89, 9105 \mapsto 6,\ 6 \mapsto 7,\ 7 \mapsto 8,\ 8 \mapsto 9,\ 9 \mapsto 10, with 0,1,2,3,40, 1, 2, 3, 4 unchanged.

The keleven string “853” has digit values 9,6,39, 6, 3, so as a base-1111 number, 9121+611+3=1089+66+3=1158.9 \cdot 121 + 6 \cdot 11 + 3 = 1089 + 66 + 3 = 1158. “520” has digit values 6,2,06, 2, 0, so 6121+211+0=748.6 \cdot 121 + 2 \cdot 11 + 0 = 748. Their sum is 19061906. Convert 19061906 to base-1111: 1906=1113+4112+811+31906 = 1 \cdot 11^3 + 4 \cdot 11^2 + 8 \cdot 11 + 3. Digit values 1,4,8,31, 4, 8, 3, which as keleven symbols are 1,4,7,31, 4, 7, 3 (since 88 as a value writes as the symbol 77). The base-1111 representation is “14731473.” Match.

Check the multiplication. “41” = 411+1=454 \cdot 11 + 1 = 45; “26” has digit values 2,72, 7, so 211+7=292 \cdot 11 + 7 = 29; their product is 4529=130545 \cdot 29 = 1305. In base-1111, 1305=10121+811+71305 = 10 \cdot 121 + 8 \cdot 11 + 7, digit values 10,8,710, 8, 7, which in keleven symbols are 9,7,69, 7, 6. The base-1111 representation is “976976.” Match.

Keleven lies between 4 and 5.\boxed{\,\text{Keleven lies between } 4 \text{ and } 5.\,}

A short argument why this is the unique answer: the first equation gives 8+5=138 + 5 = 13 in keleven, but the displayed result reads “14731473,” i.e. a 11 then a 44 in the hundreds. So the hundreds-place sum, base-1010, equals 1414 (111+41\cdot 11 + 4 - carries) or 1515. This rules out KK between 3\le 3 and 6\ge 6, narrowing to K{4,5}K \in \{4, 5\}. The tens digit “77” read against the keleven addition then forces KK between 44 and 55.

The computation

Sweep KK’s position from 00 to 99; check both equations for each candidate.

  1. For each insertion point dd, build the symbol-to-value map.

  2. Convert each keleven string to its base-1010 value; compute sum and product.

  3. Convert the answer back to base-1111 digit values, then to keleven symbols.

  4. The candidate is valid only if both equations round-trip.

def sym_to_val(s, d):
    out = []
    for c in s:
        v = int(c)
        out.append(v if v <= d else v + 1)
    return out

def val_to_sym(vals, d):
    out = []
    for v in vals:
        if v == d + 1:
            out.append("K")
        else:
            out.append(str(v if v <= d else v - 1))
    return "".join(out)

def kelven_to_int(s, d):
    n = 0
    for v in sym_to_val(s, d):
        n = n * 11 + v
    return n

def int_to_kelven(n, d):
    if n == 0:
        return "0"
    vals = []
    while n > 0:
        vals.append(n % 11)
        n //= 11
    return val_to_sym(list(reversed(vals)), d)

for d in range(10):
    add_lhs = kelven_to_int("853", d) + kelven_to_int("520", d)
    mul_lhs = kelven_to_int("41", d) * kelven_to_int("26", d)
    if int_to_kelven(add_lhs, d) == "1473" and \
       int_to_kelven(mul_lhs, d) == "976":
        print("K between", d, "and", d + 1)            # 4 and 5

The sweep prints exactly one match: KK between 44 and 55.

Riddle 3

A test (SAAD) has 100100 questions, each with two bubbles. Filling in the correct bubble for question ii gains ii points; filling in the incorrect bubble loses ii points. The student knows after each question whether it was right or wrong (before deciding the next). A student may also skip a question: skipping scores zero and resets the next question’s value back to 11. The second question is worth 22 points (or 11, if the first was skipped), and so on. What strategy maximises the expected score?

The Riddler, FiveThirtyEight, November 17, 2017(original post)

Solution

Each question is a fair Bernoulli: filling in either bubble has a 5050% chance of being right. The score on a non-skipped question is ±i\pm i with equal probability, so its expected contribution is exactly 00. Skipping contributes 00. Whatever strategy you adopt, by linearity of expectation, E[final score]=actionsE[score of action]=0.\mathbb{E}[\text{final score}] = \sum_{\text{actions}} \mathbb{E}[\text{score of action}] = 0. No strategy can beat E=0\mathbb{E} = 0. The variance, however, depends sharply on the strategy: skipping everything yields a deterministic score of 00 (variance 00); answering all questions has variance i=1100i2=1001012016=338,350\sum_{i=1}^{100} i^2 = \tfrac{100 \cdot 101 \cdot 201}{6} = 338{,}350. From the standpoint of a rational decision maker the deterministic-zero strategy is the one to pick: same expected value, no variance.

(The official Riddler answer puts the same conclusion more colourfully: “A strange game. The only winning move is not to play.”)

The computation

Simulate any strategy and confirm the empirical mean is zero to sampling precision; sweep over a small zoo of strategies (answer all; skip the high-value tail; alternating; skip-after-loss).

  1. For each strategy, simulate one test by deciding (per question) to answer or skip and tossing a fair coin for correctness on answered questions.

  2. Track running points: +v+v on a correct answer of current-value vv, v-v on incorrect, 00 on skip (and reset vv to 11).

  3. Average the final scores over many runs.

import random

def run_test(strategy, seed):
    rng = random.Random(seed)
    v, score = 1, 0
    for q in range(100):
        skip = strategy(q, v, score)
        if skip:
            v = 1
            continue
        win = rng.random() < 0.5
        score += v if win else -v
        v += 1
    return score

def s_answer_all(q, v, s): return False
def s_skip_all(q, v, s):   return True
def s_skip_after_loss(q, v, s):
    return v > 1 and s < 0

for name, S in [("all", s_answer_all), ("skip", s_skip_all),
                ("after_loss", s_skip_after_loss)]:
    N = 20_000
    mean = sum(run_test(S, k) for k in range(N)) / N
    print(name, "mean =", round(mean, 2))           # ~ 0

Every strategy averages close to zero; only skipping every question achieves it deterministically.