This year's Spring Festival Gala
Magician Liu Qian performed a magic trick related to playing cards
The exquisite design brought a high sense of participation to the audience
Many people took out the playing cards at home
"Witness the miracle" with Liu Qian
" "Little Ni's playing cards didn't match up"
also appeared on the hot search
What is the mystery behind this magic "miracle"
?
While the Spring Festival Gala is still in progress
School of Mathematical Sciences, Peking University
2021 undergraduates Liu Minghao, Li Xinyu, Yin Ziying
2022 undergraduates Wang Ziru, Huang Tianming, Wang Meitan
2023 undergraduates Pan Haoxiang and Wang Weisheng
wrote a popular science article
Let everyone experience the charm of this magic from a mathematical perspective
Magic steps
First, prepare 4 playing cards
Follow the magic steps
to "witness the miracle" together
Steps 1
Tear the prepared 4 playing cards
evenly Divide into two pieces
and stack them together
Step 2
Move the card with the number of words on the top of the deck
to the bottom of the deck
Step 3
Place the first three cards in the middle of the deck
and take out the card on the top of the deck
Set aside
Step 4
Take out some cards from the top of the deck
Insert them into the middle of the deck
The number of cards selected here is
People from the south take 1 card, people from the north take 2
If you are not sure whether it is the people from the south or the north. 3 cards
Steps 5
The boy throws away the top 1 card of the deck
The girl throws away the top 2 cards of the deck
Steps 6
Execute the "moment to witness the miracle" loop
Every time a word is said
takes out the top card of the deck and places it on the deck. Bottom of the pile
Step 7
Perform the following operations
Start from the top of the pile
Each time, first put a card from the top of the pile to the bottom
Then throw away the top card
Repeat the above operations until only one card is left. card
Check whether this card matches the card placed aside
If they match, the magic is successful
Magic Revealed
How about, do your playing cards match?
Below, several Peking University students will follow the step sequence
to reveal the logic behind it step by step
Step 1
We let the four selected playing cards be 1234, and after tearing them apart, we produced cards with the numbers 1234. Two sets (half cards) of playing cards, stacked together, form a pile of playing cards numbered 12341234 from top to bottom.
Step 2
At this point we can notice that no matter how many cards we move from the top of the deck to the bottom, the obtained poker deck numbers (from top to bottom) will only have the following results:
12341234 (name The number of words is evenly divisible by four)
23412341 (the number of characters in the name modulo four with a remainder of one)
34123412 (the number of characters in the name modulo four with a remainder of two)
41234123 (the number of characters in the name modulo four with a remainder of three)
Observing the above possible decks, we can find that the generated decks have the following Properties: 1. The order of the first four cards and the last four cards is exactly the same 2. The first four cards and the last four cards are a rotation of 1234 respectively
Step 3
From this step on, we only consider the current card pile The two cards ranked fourth and eighth are recorded as x, and the other cards are recorded as 0. Then based on the discussion in the previous step, we can get the current deck shape as:
000x000x
After placing the first three cards in the middle of the deck, no matter where these three cards are placed, the final deck will be:
x000000x
So, The card selected for matching will be x, and the other card paired with it (called the target card) will be at the bottom of the deck.
Step 4
After the previous step, the number of the deck is 000000x. Therefore, no matter how many cards are selected from the top of the deck and inserted into the deck in this round, it will not affect the position of the target card and it will still be at the bottom of the deck.
Step five
At this time, the boy's card pile is: 00000x The girl's card pile is: 0000x
Step six
It can be seen from the trial that after step six, the following card pile will be obtained: Boys: 0000x0 Girls: 00x00
Step seven
passes the above Revealing the secret
I believe it is not difficult for everyone to see that the magic behind the
is actually a mathematical problem
It is called the Joseph problem
The Joseph problem
There are n people numbered 1, 2,..., n Form a circle, start counting from the first person, stop counting when m is reached, and the person who reported m leaves the circle. Then start counting again from the next person, stop counting when m is reported, and report m out of the circle... Follow this rule until everyone is out of the circle. Ask for the number of the last person left. In order to simplify the problem, we consider the situation where n people are numbered 0 ~ n-1, and one person exits every m people, which we call the (n, m) problem. After the first person (that is, the person whose number is congruent m modulo n) exits, the remaining n-1 people are renumbered, so that the k number of the new problem corresponds to the k+m number in the original problem. Therefore, the solution to the (n, m) problem is j (n, m) = j (n-1, m)+m and j (1, m) = 1 (modulo n). Accordingly, j (n, m) can be obtained through recursion. In practice, Joseph's problem is generally solved using code. Liu Qian's magic uses the special case of m=2.
So why did host Xiaoni
fail?
Let’s take a look at the reasons behind it.
According to the above proof process, it is not difficult for us to find: in steps 3 and 4, if the operation is correct, the bottom card in each host’s hand has not changed, and this happens to be The one card left after step 7.
However, when performing step 4, pay attention to the hand movements of Nigmaiti :
The camera captured that during the insertion process, the card pattern originally located at the bottom was covered by another card. In other words, Nigmaiti Ti did not put the two cards into the middle position as required, causing his final match to fail.
After listening to the explanation from Peking University students
Do you understand the mathematical problems behind the magic?