A mathematical analysis of Squid Game, game 5

A spoiler-free look at your probability of death if you were forced to play a mathematically idealized version of the game from the hit K-drama series.

October 22, 2021

If you haven’t heard of Squid Game, please contact me and perhaps I can arrange for a landscaping company to extricate you from the rock you’ve been living under. And then read this G-rated, spoiler-free rephrasing of the fifth game from Squid Game so you can understand what the rest of us are talking about (people who have seen the show, hopefully the analogy is obvious):

A teacher has N students and gives each of them the same M question true/false test. They’ve been assigned an order in which to take the test, and are quizzed one-by-one down this order. For each student, the teacher asks the same M questions in the same order. As soon as a given student gets a question wrong, that student is considered to have failed the test; the teacher then moves on to the next student in the sequence and restarts, asking the same M questions in the same order.

The students:

  • Have perfect memory, and each student is tested in front of the whole class publicly, so as soon as one student gets a question right, all subsequent students get that question right.
  • Have no idea about the content of the test, so each new question has an independent 50/50 chance of being answered right/wrong.

What’s the distribution of the number of students pass the test (get all questions correct)? For example, if N=M=2 , there’s a 1/4 chance two students pass, a 1/2 chance one student passes, and a 1/4 chance no student passes. How does this generalize with different values of N and M ?

First, note that when a teacher asks a new question (one that the class hasn’t heard yet and therefore hasn’t remembered the answer to), the class will learn the answer to this question regardless of what answer the student being tested gives. If the student answers correctly, the rest of the class will memorize that answer (and the student gets to advance to the next question); but if the student answers incorrectly, the rest of the class will simply memorize the opposite choice and learns the information regardless.

With this in mind, the students earlier in the sequence can be viewed as martyrs who reveal the answers to their later classmates, giving them a greater chance at passing. The real Squid Game is a bit different, but in this scenario, students later in the sequence have an advantage because they have strictly more information about the test than those who went earlier. The first student has only a 2^{-M} chance of passing because that student has to guess every single question correctly. In contrast, students M+1 and beyond are guaranteed to pass, because each student reveals the answer to at least one new test question, and therefore the first M students are sufficient to reveal the answers to all M questions.

Towards a recursive solution

To formalize some of these intuitions, define p_{a,b} as the probability that a students have yet to fail by the time the class learns the answers to the first b questions. We know p_{N,0}=1 because none of the N students have failed when the testing begins. Our goal of finding the distribution over number of passing students is equivalent to finding p_{i, M} for i\in[0..N] because having exactly i students pass the test is equivalent to i students not fail by the time the answers to all M questions are revealed.

Let’s try to define a recursive solution to our problem. If a students have yet to fail and the class knows the answers to the first b questions, the following two events occur with equal 50/50 probability when the b+1 th question is asked:

  • It’s guessed correctly, so a students have yet to fail.
  • It’s guessed incorrectly, so a-1 students have yet to fail.

Either way, the answer to the b+1 th question will be revealed, as discussed before. This implies half of p_{a,b} goes to p_{a,b+1} and the other half goes to p_{a-1,b+1} . The only exception to this recursion is when a=0 ; in that case, since everyone has failed and therefore no additional students can fail, all of p_{a,b} goes to p_{a,b+1} . Using our recursion, we can generate the following table for N=M=3 , where the arrows denote the recursive relationships that transfer probability mass.

\begin{array}{cc|ccccccc} && &&& a &&& \\ && 0 && 1 && 2 && 3 \\ \hline & 0& &&&&&& 1 \\ && &&&&& \swarrow & \downarrow \\ & 1& &&&& 1/2 && 1/2 \\ b && &&& \swarrow & \downarrow & \swarrow & \downarrow \\ & 2& && 1/4 && 2/4 && 1/4 \\ && & \swarrow & \downarrow & \swarrow & \downarrow & \swarrow & \downarrow \\ & 3& 1/8 && 3/8 && 3/8 && 1/8 \\ \end{array}

If you ignore the denominators of the fractions, you’ll find Pascal’s triangle. In fact, what we generated is Pascal’s triangle, but divided by 2^b . This is no coincidence; it turns out that our recursion for p_{a,b} is exactly Pascal’s identity, but halved. This leads to the powers of two in the denominators. Additionally, the i th row of Pascal’s triangle sums to 2^i , but our i th row is then divided by 2^i , so each row sums to 1 in our case. This makes perfect sense because each row is a probability distribution over how many students have passed the first i questions, and probability distributions must add to 1.

Thanks to the fact that the j th entry in the i th row of Pascal’s triangle is \binom{i}{j} , we can say (after some finagling the indexing) that p_{a,b} = \binom{b}{N-a}/2^ b when N-a\le b , and 0 otherwise. This indexing is kind of awkward and can be cleaned up once we realize that a is the number of students who have yet to fail, so N-a is the number of students who have failed. If we define p’_{a,b} as the probability a students have failed by the time the class learns the answers to the first b questions, our answer becomes cleaner:

  • p’_{a,b}=\binom{b}{a}/2^b if a\le b .
  • Otherwise, p’_{a,b}=0 .

Another less symbol-heavy way of stating this result is that the number of students who fail the exam follows a binomial distribution with M trials and success probability 0.5 . This connection illustrates a well-known relationship between Pascal’s triangle and the binomial distribution.

Edge cases

Unfortunately when N< M , our math breaks down a bit because we need to consider the edge case of our recursion when all students have failed. Visually, our table is taller than it is fat in these cases, and the result isn’t quite the binomial distribution. For example, if N=3 , M=5 we get:

\begin{array}{cc|ccccccc} && &&& a &&& \\ && 0 && 1 && 2 && 3 \\ \hline & 0& &&&&&& 1 \\ && &&&&& \swarrow & \downarrow \\ & 1& &&&& 1/2 && 1/2 \\ && &&& \swarrow & \downarrow & \swarrow & \downarrow \\ & 2& && 1/4 && 2/4 && 1/4 \\ b && & \swarrow & \downarrow & \swarrow & \downarrow & \swarrow & \downarrow \\ & 3& 1/8 && 3/8 && 3/8 && 1/8 \\ && \downarrow & \swarrow & \downarrow & \swarrow & \downarrow & \swarrow & \downarrow \\ & 4& 5/16 && 6/16 && 4/16 && 1/16 \\ && \downarrow & \swarrow & \downarrow & \swarrow & \downarrow & \swarrow & \downarrow \\ & 5& 16/32 && 10/32 && 5/32 && 1/32 \\ \end{array}

Our results for p_{0,b} are incorrect for b>N . But this actually turns out to be very easy to fix; since only the leftmost column of the table is affected, and we know every row of the table sums to 1, we can fill in the leftmost entry as one minus the sum of the rest of the row. For example, p_{0,5}=1-p_{1,5}-p_{2,5}-p_{3,5}=16/32 .

So, to summarize our results, if we have N students and an M -question test:

  • If N\ge M :
    • There’s a \binom{M}{k}\cdot2^{-M} probability that exactly k students fail the test, for k\in[0..M] . There’s a zero probability that more than M students to fail.
    • The k th student passes the test if fewer than k students fail the test. The probability the k th student passes is therefore 2^{-M}\sum_{i=0}^{k-1}\binom{M}{i} if k\le M ; otherwise, k> M so the student is late enough in the sequence to be guaranteed to pass.
  • Else (which implies N< M ):
    • There’s a \binom{M}{k}\cdot2^{-M} probability that exactly k students fail the test, for k\in[0..N-1] .
    • Theres a 1-2^{-M}\sum_{i=0}^{N-1}\binom{M}{i} probability that all N students fail the test.

Plots and stuff

We already have our results in symbolic form above, but below are a few visualizations to present the results in another angle.

Suppose there are N=10 students and M=12 questions. What is the probability exactly k students pass, for varying k ?


Suppose there are M=12 questions. What’s the probability that the k th student passes, for varying k ? This is basically plotting the CDF of the binomial distribution; as explained earlier, the probability is 1 for k>12 .


Suppose there are N=10 students. What’s the expected number of students that pass if there are M questions, for varying M ? Here we can see a linear decrease in expectation until M=10 ; from then on, we begin to hit the edge case of our recursion that results in a truncated binomial distribution. The expectation then gradually approaches 0 as M grows.