Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 212

In Space, No One Can Hear Your 3D Printer Die

Riddler Express

I multiplied together some of the integers from 11 to 9999. I got a big number in return:

530,131,801,762,787,739,802,889,792,754,109,70?,139,358,547,710,530{,}131{,}801{,}762{,}787{,}739{,}802{,}889{,}792{,}754{,}109{,}70\underline{?}{,}139{,}358{,}547{,}710{,}
066,257,652,050,346,294,484,433,323,974,747,960,297,803,066{,}257{,}652{,}050{,}346{,}294{,}484{,}433{,}323{,}974{,}747{,}960{,}297{,}803{,}
292,989,236,183,040,000,000,000.292{,}989{,}236{,}183{,}040{,}000{,}000{,}000.

What is the missing digit?

The Riddler, FiveThirtyEight, January 11, 2019(original post)

Solution

The missing digit is recovered by casting out nines, provided the product is divisible by 99. Show that first, then read off the digit.

Why the product must be divisible by 99. The product is taken over some subset of {1,2,,99}\{1, 2, \ldots, 99\}. The published number has 114114 digits, of which the rightmost 1212 are trailing zeros. The number is therefore enormous: any subset whose product reaches this size must include nearly every available factor, in particular more than one multiple of 33. To see this concretely, the largest product over any subset of {1,,99}\{1, \ldots, 99\} that includes exactly one multiple of 33 is bounded above by 961k993kk,96 \,\cdot\, \prod_{\substack{1 \le k \le 99 \\ 3 \,\nmid\, k}} k, where 9696 is the largest single multiple of 33 in the range and the second factor is the product of the 6666 integers in {1,,99}\{1, \ldots, 99\} coprime to 33. A direct calculation (or even a crude logarithmic estimate) shows this bound is many orders of magnitude below the puzzle’s 114114-digit number. The puzzle’s product therefore contains at least two distinct multiples of 33, hence two factors of 33, hence a factor of 99.

Casting out nines. A number is divisible by 99 if and only if the sum of its digits is divisible by 99. Let dd be the missing digit. Summing the known digits of the number with dd in the masked slot gives Sknown  +  d    0(mod9).S_{\text{known}} \;+\; d \;\equiv\; 0 \pmod{9}. A direct sum of the 107107 known digits (the missing slot replaced by 00 for bookkeeping) yields Sknown=471S_{\text{known}} = 471, and 471=952+3471 = 9 \cdot 52 + 3, so Sknown3(mod9)S_{\text{known}} \equiv 3 \pmod{9}. Hence d    3    6(mod9).d \;\equiv\; -3 \;\equiv\; 6 \pmod{9}. The only single digit in {0,1,,9}\{0, 1, \ldots, 9\} congruent to 6(mod9)6 \pmod 9 is 66 itself (d=6d = 6; d=15d = 15 would not be a digit).

Missing digit  =  6.\boxed{\text{Missing digit} \;=\; 6.}

The computation

Encode the problem directly: take the number as given, with the missing digit marked, and find the digit that makes the digit sum a multiple of 99. No reliance on the derivation: the script just sweeps d{0,,9}d \in \{0, \ldots, 9\} and reports the unique value that works.

  1. Write out the digit string with the missing slot.

  2. For each candidate d{0,,9}d \in \{0, \ldots, 9\}, replace the slot with dd and test divisibility by 99 via the digit sum.

  3. Report the unique dd that passes.

groups = (
    "530,131,801,762,787,739,802,889,792,754,109,70?,139,358,"
    "547,710,066,257,652,050,346,294,484,433,323,974,747,960,"
    "297,803,292,989,236,183,040,000,000,000"
).split(",")
number_with_slot = "".join(groups)
candidates = [d for d in range(10)
              if sum(int(c) for c in number_with_slot.replace("?", str(d)))
                 % 9 == 0]
print("Digits making the number divisible by 9:", candidates)

The script prints the single-element list [6][6], matching the boxed answer.

Riddler Classic

Congratulations, astronaut! You have been selected for the first manned mission to Mars and will spend five Earth-years on the surface, that is 1,8251{,}825 Earth-days (no leap years). Exactly one vital piece of equipment will break each day. You and the crew bring three 33D printers to print replacement parts. Each printer is from a different country, so parts from one printer are incompatible with the others (no scavenging). When a printer itself breaks, one of the other printers must print its replacement part. Parts print effectively instantly, but any given printer can print at most one piece per day. In addition to the daily vital-equipment break, the three printers have independent daily break probabilities 0.100.10, 0.0750.075, and 0.050.05. If you cannot print a replacement for any piece of vital equipment, you die. What is the probability you make it home alive?

The Riddler, FiveThirtyEight, January 11, 2019(original post)

Solution

Reduce the daily survival condition first; then the 1,8251{,}825-day question becomes a single Bernoulli product.

The daily survival condition. Let AA, BB, CC be the three printers with daily break probabilities pA=0.10p_{A} = 0.10, pB=0.075p_{B} = 0.075, pC=0.05p_{C} = 0.05, and let k{0,1,2,3}k \in \{0, 1, 2, 3\} be the number of them that break on a given day. The astronaut also needs to print one replacement for the vital equipment that day. Print demands and capacities, considered for the day’s schedule:

  • k=0k = 0: no printer is broken; any printer can print the vital part. Survives.

  • k=1k = 1: two working printers remain; use one of them to print the broken printer’s part (it is then operational), and the other (or the just-repaired one) to print the vital part. Survives.

  • k=2k = 2: one working printer remains. Suppose AA and BB both break and CC is alive. Order the print jobs within the day: CC prints AA’s part (so AA is now working), then AA prints BB’s part (so BB is now working), then BB prints the vital-equipment part. Each printer does at most one job, so the one-piece-per-printer-per-day budget is met. Survives.

  • k=3k = 3: all three printers break on the same day. No printer is alive to print anyone’s first repair. The vital part cannot be made. Dies.

So the day is survived if and only if at least one printer is working at the start of the day, which is the same as saying not all three broke. (Printers that broke are restored by day’s end whenever a chain of repairs is possible, which the case analysis just showed it is whenever k2k \le 2. The next morning therefore starts with all three printers operational again.) The daily failure probability is q  =  pApBpC  =  0.100.0750.05  =  3.75104.q \;=\; p_{A} \, p_{B} \, p_{C} \;=\; 0.10 \cdot 0.075 \cdot 0.05 \;=\; 3.75 \cdot 10^{-4}.

Surviving 1,8251{,}825 days. The day-to-day failure events are independent because, after any successful day, all three printers are operational, and the next day’s breakages are drawn from the same independent triple. Hence Pr(survive all 1,825 days)  =  (1q)1825  =  (0.999625)1825    0.5043.\begin{aligned} \Pr(\text{survive all } 1{,}825 \text{ days}) &\;=\; (1 - q)^{1825} \;=\; (0.999625)^{1825} \\ &\;\approx\; 0.5043. \end{aligned}

Pr(survive)  =  (10.100.0750.05)1825    50.43%.\boxed{\Pr(\text{survive}) \;=\; (1 - 0.10 \cdot 0.075 \cdot 0.05)^{1825} \;\approx\; 50.43\%.}

The computation

Simulate the calendar directly: each day, draw three independent break indicators; if all three break, the mission ends. Otherwise the day is survived and the printers reset. Compare the empirical survival rate over many trials to the closed form.

  1. For each trial, walk through 1,8251{,}825 days.

  2. On each day, draw three independent Bernoulli break flags with probabilities 0.100.10, 0.0750.075, 0.050.05.

  3. If all three break, the trial is a death; otherwise continue.

  4. Report the empirical survival probability and compare to (1q)1825(1 - q)^{1825}.

import random

def simulate(trials=200_000, days=1825, seed=0):
    rng = random.Random(seed)
    ps = (0.10, 0.075, 0.05)
    survived = 0
    for _ in range(trials):
        alive = True
        for _day in range(days):
            if all(rng.random() < p for p in ps):
                alive = False
                break
        if alive:
            survived += 1
    return survived / trials

q = 0.10 * 0.075 * 0.05
closed = (1 - q) ** 1825
print(f"closed form = {closed:.4f}")
print(f"simulated   = {simulate():.4f}")

The script prints closed form=0.5043\text{closed form} = 0.5043 and simulated0.5043\text{simulated} \approx 0.5043 (within Monte-Carlo noise of ±0.002\pm 0.002 at 200,000200{,}000 trials), matching the boxed answer.