Introduction

During the 2024 Spring Festival Gala, many people were amazed by Liu Qian's second magic trick. I tried it myself and quickly uncovered the mathematical principle behind it. Let me explain it to you.

What Is The Magic Trick

First, let's break down how this magic trick is performed.

Start by preparing 4 different playing cards. Split these 4 cards in half and stack the two halves together. Then, based on the number of characters in your name, move that many cards one by one from the top to the bottom.

Next, take the top 3 cards and insert them into the middle of the deck (random positions, same below). Then take out the top card and set it aside—this will be part of the final card combination.

After setting it aside, if you consider yourself from the south, insert the top card into the middle; if from the north, insert the top 2 cards into the middle; and if unsure, insert the top 3 cards into the middle.

Then, based on gender, boys discard the top card, and girls discard the top 2 cards.

Next, move 7 cards one by one from the top to the bottom.

Then repeat the following operation: move the first card to the bottom, discard the second card (now on top). Continue this until only one card remains in your hand.

At this moment, the remaining card in your hand and the card you set aside earlier will form a complete card.

Magic Trick Revelation

This magic trick relies on the theory of congruence. We need to prove that the final two selected cards are congruent $\mod 4$.

Let's demonstrate the changes in the card formation throughout the process.

STEP 1

For simplicity, let's assume these 4 cards are $A_1, A_2, A_3, A_4$. After splitting them in half and stacking them together, the deck becomes $A_1, A_2, A_3, A_4, A_1, A_2, A_3, A_4$. We can see that the distance between paired cards is 4.

STEP 2

Next, based on the number of characters in your name, moving the top cards to the bottom is a circular stack operation, which does not affect the distance between paired cards regardless of how many times it is executed. This step is a red herring, making people think that different name lengths result in different card formations. If you consider the deck as a "circle," you will see that this step does not change the card structure. For example, my name has 2 characters, so after moving two cards from the top to the bottom, the deck becomes $A_3, A_4, A_1, A_2, A_3, A_4, A_1, A_2$.

STEP 3

The next step is crucial. Insert the top 3 cards into the middle of the deck at random positions, then take the top card. It must be 3 cards because only then can the taken card pair with the card at the bottom. At this point, we only need to focus on the position of the card that pairs with the taken card; the positions of the other cards are irrelevant. Therefore, we can simplify the deck to $C, C, C, C, C, C, A$, where $A$ is the card we are focusing on for pairing.

STEP 4

With the above simplification, the next step of inserting cards based on the north or south does not affect the card formation. Since it is an insertion, the card $A$ we are focusing on remains at the bottom. Therefore, this is another red herring.

STEP 5

Next, boys discard the top card, and girls discard the top 2 cards. This results in two situations:

$$
\begin{align*}
\text{Boys} &\quad C, C, C, C, C, A \\
\text{Girls} &\qquad\; C, C, C, C, A
\end{align*}
$$

We will later prove that this difference is unimportant and can be smoothed out.

STEP 6

Move 7 cards one by one from the top to the bottom. This is still a "circular stack" operation that does not change the card structure, but its most important function is to move the bottom card to the correct position for the next step. After moving, the card formation becomes:

$$
\begin{align*}
\text{Boys} &\quad C, C, C, C, A, C \\
\text{Girls} &\qquad\; C, C, A, C, C
\end{align*}
$$

STEP 7

Repeat the following operation: move the first card to the bottom, discard the second card (now on top). Continue this until only one card remains in your hand.

This process is equivalent to continuously discarding cards with $\mod 2 \equiv 0$ positions from the circle (assuming the position index starts from 1). We find that boys only need to do this once for the card formation to become $C, C, A, C, C$, the same as the girls' card formation. Therefore, we only need to look at the changes in the girls' card formation:

$$
\begin{align*}
\text{1st time} \quad & A, C, C, C \\
\text{2nd time} \quad & C, C, A \\
\text{3rd time} \quad & A, C \\
\text{4th time} \quad & A
\end{align*}
$$

You can see that the final remaining card is the one that can pair successfully.

Conclusion

This magic trick is essentially a mathematical problem with some red herrings. Once we strip away these misleading steps and focus on the simplified structure of the problem, everything becomes very clear. Magic, after all, is just like this!