This week’s Riddler Express problem is a nod to the recently released finale to the Avengers saga. No spoilers!
Thanos, the all-powerful supervillain, can snap his fingers and destroy half of all the beings in the universe.
But what if there were 63 Thanoses, each snapping his fingers one after the other? Out of 7.5 billion people on Earth, how many can we expect would survive?
If there were N Thanoses, what would the survival fraction be?
Here is my solution:
[Show Solution]
First things first: If there are $S$ Thanos snaps and the probability of survival after one snap is $p$, then the expected fraction of survivors is $p^S$. In the case where the population is $7.5$ billion and the probability of survival is $p=0.5$, if there are $S=63$ snaps, we can calculate the expected number of survivors to be:
\[
\frac{7.5\times 10^9}{2^{63}} = 8.13\times 10^{-10}
\]This number is so small that there will almost certainly be no survivors.
A more interesting interpretation: But what if Thanos were not immune to the snap? After all, when Thanos snaps his fingers, half of all the beings in the universe are destroyed! This should include Thanos! So when the first Thanos snaps his fingers, on average half of the remaining Thanoses will be destroyed before having the opportunity to snap their fingers.
This means that $S$, the total number of snaps, is a random variable. We can compute its probability mass function recursively. Specifically, let’s define $P_N(s)$ to be the probability that there will be $S=s$ snaps given that there are initially $N$ Thanoses. Let’s start with some easy cases.
- If there are no Thanoses, there will be no snaps. So $P_0(0) = 1$.
- If there is at least one Thanos, there will be at least one snap. So $P_N(0) = 0$ for $N=1,2,\dots$.
The recursion for larger values of $s$ is given by:
\begin{align}
P_N(s) &= \sum_{k=0}^{N-1} \mathrm{Prob}(k\text{ Thanoses survive first snap}) P_k(s-1) \\
&= \sum_{k=0}^{N-1} \binom{N-1}{k} p^{k}(1-p)^{N-1-k} P_{k}(s-1)
\end{align}This follows because if there are $s$ snaps remaining, then during the first one, the remaining $N-1$ Thanoses are at risk of destruction. The number of surviving Thanoses follows a binomial distribution with $N-1$ trials and probability $p$, which explains why the probability that $k$ survive the first snap is equal to $\binom{N-1}{k} p^{k}(1-p)^{N-1-k}$. This recursion can be evaluated numerically. Here is what the distribution of snaps looks like for $p=0.5$ and $N=63$:
So there will most likely be $5$ or $6$ snaps. Once we know how many snaps there are, the effect on the population of the universe is the same as in the first interpretation. So the expected fraction of survivors in the universe will be $\mathbb{E}(p^S)$, or:
\[
\mathbb{E}(\text{fraction of survivors if we have }N\text{ Thanoses}) = \sum_{s=0}^N p^s P_{N}(s)
\]Here is a plot of the surviving fraction as a function of $N$ when $p=0.5$:
When there are 63 Thanoses, the expected survival rate is about 2.22%. So with an initial population of 7.5 billion, we will be left with, on average, about 166.5 million.
If you’re curious about the shape of this graph, we can approximate it like this: With $N$ Thanoses and $p=0.5$, there are roughly $\log_2(N+1)$ flips that occur. If exactly that many flips occur, the fraction of survivors will be roughly $(0.5)^{\log_2(N+1)} = \tfrac{1}{N+1}$. This tells us that as $N$ gets large, the fraction of survivors will scale roughly like $\frac{1}{N}$, where $N$ is the number of Thanoses. This is a crude approximation, but it captures the correct asymptotic behavior.
If you’re interested in the (Python) code I wrote to generate this solution (and the figures), you can find it on github here.





















