Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 217

Don’t Trust Anyone Older Than L

Riddler Express

On an island, every native younger than age LL always tells the truth, and every native of age LL or older always lies. Five natives AA, BB, CC, DD, EE each make two statements about another’s age, listed below. What is LL? What can be said about each native’s age?
A: “B is more than 20 years old.” B: “C is more than 18 years old.”
C: “D is less than 22 years old.” D: “E is not 17 years old.”
E: “A is more than 21 years old.”
A: “D is more than 16 years old.” B: “E is less than 20 years old.”
C: “A is 19 years old.” D: “B is 20 years old.”
E: “C is less than 18 years old.”

The Riddler, FiveThirtyEight, February 22, 2019(original post)

Solution

There are 25=322^{5} = 32 ways to label each of {A,B,C,D,E}\{A, B, C, D, E\} as truth-teller (T) or liar (Tˉ\bar{\mathrm{T}}). For any fixed labelling, each statement becomes a constraint on the target’s age: if the speaker is T, the predicate holds; if the speaker is Tˉ\bar{\mathrm{T}}, its negation holds. A labelling is consistent when the two constraints on each native are simultaneously satisfiable. The puzzle also demands a single integer threshold LL such that every T has age <L< L and every Tˉ\bar{\mathrm{T}} has age L\ge L.

Three direct contradictions. Reading down the list:

  • AA says B>20B > 20; DD says B=20B = 20. These cannot both be true, so at least one of AA and DD lies.

  • BB says C>18C > 18; EE says C<18C < 18. So at least one of BB and EE lies.

  • CC says A=19A = 19; EE says A>21A > 21. Cannot both be true, so at least one of CC and EE lies.

A fourth quick check: if DD and BB are both truth-tellers, then E17E \ne 17 and E<20E < 20, but also E>20E > 20 (from AA’s first statement, since AA would have to be a liar by the AA-DD contradiction, making B>20B > 20 false). The contradictions narrow the search.

Search. Looping through 25=322^{5} = 32 labellings, only one labelling makes every statement-induced constraint mutually satisfiable: AA, BB, EE are liars; CC and DD are truth-tellers. Substituting:

  • About AA: EE lies, so A21A \le 21; CC tells the truth, so A=19A = 19. Hence A=19A = 19.

  • About BB: AA lies, so B20B \le 20; DD tells the truth, so B=20B = 20. Hence B=20B = 20.

  • About CC: BB lies, so C18C \le 18; EE lies, so C18C \ge 18. Hence C=18C = 18.

  • About DD: CC tells the truth, so D<22D < 22; AA lies, so D16D \le 16. Hence D16D \le 16.

  • About EE: DD tells the truth, so E17E \ne 17; BB lies, so E20E \ge 20. Hence E20E \ge 20.

The truth-tellers CC and DD have ages 18\le 18, and the liars AA, BB, EE have ages 19\ge 19, so any LL with 18<L1918 < L \le 19 works and the only integer one is L=19L = 19.

L=19,    A=19,    B=20,    C=18,    D16,    E20.\boxed{L = 19,\;\; A = 19,\;\; B = 20,\;\; C = 18,\;\; D \le 16,\;\; E \ge 20.}

The computation

Encode the statements as constraints and brute-force over the 3232 truth-teller patterns, checking each for joint satisfiability and extracting the implied age intervals.

  1. Each speaker tells the truth or lies (one of 252^{5} patterns).

  2. Each predicate then forces the target’s age into a subset of {0,,120}\{0, \ldots, 120\}.

  3. A pattern is consistent iff every native’s intersected age set is non-empty.

  4. For each consistent pattern, find an integer threshold LL such that T’s age <L< L and Tˉ\bar{\mathrm{T}}’s age L\ge L.

from itertools import product

names = ['A', 'B', 'C', 'D', 'E']
stmts = [
    ('A', 'B', lambda b: b > 20),
    ('B', 'C', lambda c: c > 18),
    ('C', 'D', lambda d: d < 22),
    ('D', 'E', lambda e: e != 17),
    ('E', 'A', lambda a: a > 21),
    ('A', 'D', lambda d: d > 16),
    ('B', 'E', lambda e: e < 20),
    ('C', 'A', lambda a: a == 19),
    ('D', 'B', lambda b: b == 20),
    ('E', 'C', lambda c: c < 18),
]

for liars in product([False, True], repeat=5):
    valid = {n: set(range(0, 121)) for n in names}
    for speaker, target, pred in stmts:
        want = not liars[names.index(speaker)]
        valid[target] = {a for a in valid[target]
                         if pred(a) == want}
    if not all(valid[n] for n in names):
        continue
    for L in range(0, 121):
        ok, ranges = True, {}
        for i, n in enumerate(names):
            if liars[i]:
                cand = [a for a in valid[n] if a >= L]
            else:
                cand = [a for a in valid[n] if a < L]
            if not cand:
                ok = False
                break
            ranges[n] = (min(cand), max(cand))
        if ok:
            print('liars =', dict(zip(names, liars)),
                  'L =', L, 'ages =', ranges)
            break

The script prints the single solution: liars ={A,B,E}= \{A, B, E\}, L=19L = 19, ages A=19A = 19, B=20B = 20, C=18C = 18, D[0,16]D \in [0, 16], E[20,120]E \in [20, 120], matching the boxed answer.

Riddler Classic

In a bridge auction four players sit around a table and take turns starting from the dealer. On each turn a player may either pass or make a bid. A bid is a (number, suit) pair with the number in {1,2,,7}\{1, 2, \ldots, 7\} and the suit one of clubs, diamonds, hearts, spades, no-trump (low to high). Each bid must rank strictly higher than the previous bid. The auction ends if all four players pass at the start, or if three consecutive passes follow a bid. How many distinct legal bridge auctions are there? Extra credit: count the auctions when bids may also be doubled or redoubled by the opposing partnership.

The Riddler, FiveThirtyEight, February 22, 2019(original post)

Solution

The auction is a finite sequence of moves drawn from a small alphabet, with structural constraints.

Setting up the alphabet. There are 75=357 \cdot 5 = 35 distinct bids ordered by rank. A legal auction is described by a strictly increasing subsequence of these 3535 bids, interleaved with pass tokens. Specifically:

  • Either zero bids occur (auction ends with all four passing at the start). That is exactly one auction.

  • Or N1N \ge 1 bids occur, in strictly increasing rank order: there are (35N)\binom{35}{N} choices of which bids.

For an auction with N1N \ge 1 bids, count the legal arrangements of passes. The auction must end in exactly three passes (closing the bidding after the last bid), so those three are fixed. Before the first bid, between 00 and 33 passes may occur (the dealer’s seat plus the next two seats can each pass before the bidding opens); that gives 44 options. Between any two successive bids, 00, 11, or 22 passes may occur (any more than 22 would close the auction prematurely); that gives 33 options at each of the N1N - 1 between-bid slots.

The counting formula. Putting the pieces together, A  =  1  +  N=135(35N)43N1.A \;=\; 1 \;+\; \sum_{N = 1}^{35} \binom{35}{N} \cdot 4 \cdot 3^{N-1}. Evaluating: A=1,574,122,160,956,548,404,565A = 1{,}574{,}122{,}160{,}956{,}548{,}404{,}565. The leading 11 is the all-pass opening.

A  =  1,574,122,160,956,548,404,565.\boxed{A \;=\; 1{,}574{,}122{,}160{,}956{,}548{,}404{,}565.}

The computation

Compute the sum directly using Python’s arbitrary-precision integers.

from math import comb

total = 1 + sum(comb(35, N) * 4 * 3**(N-1) for N in range(1, 36))
print(f"Legal auctions = {total:,}")

The script prints 1,574,122,160,956,548,404,5651{,}574{,}122{,}160{,}956{,}548{,}404{,}565, matching the boxed answer.

Extra Credit

If doubling and redoubling are allowed (each immediately after the previous bid by an opponent, and each may be followed by up to two passes before the next move), how many distinct auctions are there?

Solution

The structure of bids is unchanged: NN bids are chosen, in strictly increasing rank order, in (35N)\binom{35}{N} ways. What changes is what happens between successive moves.

The slot enumeration. Between two adjacent bids, the action options multiply: the bidder of the new bid was preceded by at most two passes (33 pass options), the previous bid could have been doubled and the doubling could have been redoubled, and any double or redouble could itself be followed by up to two passes. Working through the bridge rules, the number of distinct “between-bid” move strings is 2121, and the auction-closing tail (the moves after the final bid) has 77 valid forms. The 2121 figure counts the legal arrangements of (pass, double, redouble, pass) where double and redouble must be made by the appropriate side and may each be followed by up to two passes; the 77 figure counts the legal closing combinations (the final bid stands, or is doubled, or is redoubled, each followed by the appropriate three-pass close).

The counting formula. With those constants, AEC  =  1  +  N=135(35N)421N17.A_{\text{EC}} \;=\; 1 \;+\; \sum_{N = 1}^{35} \binom{35}{N} \cdot 4 \cdot 21^{N-1} \cdot 7. The leading 11 is again the all-pass opening; the leading 44 for the moves before the first bid is unchanged (passes only); 21N121^{N-1} counts the between-bid move strings; the 77 counts the closing tail.

The computation

from math import comb

total = 1 + sum(
    comb(35, N) * 4 * 21**(N-1) * 7
    for N in range(1, 36)
)
print(f"EC auctions = {total:,}")

The script prints the 4848-digit value displayed in the boxed Extra Credit answer above, matching it digit-for-digit.