Science Squirrel Club? Math Magic Series: The Magician's Coin

During a magic show, a magician dressed in black walked onto the stage and scattered ten coins on the table. Through the image reflected by the projector, the audience could clearly see on the big screen that some of the coins had the numbers facing up on the front and others had the national emblem facing up on the back, with no discernible pattern.

Then the magician said, "Today I'm going to perform a coin toss magic trick, and I need an audience member to help me." An audience member walked onto the stage, and the magician said, "You can choose any of these ten coins to flip over. To make it easier, let's use the last digit of your phone number. Could you please tell me the last digit of your phone number?" The audience member replied, "It's 3." "Okay, now I'll turn my back. You can choose any three coins and flip them over, then randomly arrange the coins, scramble them, and then choose one you like to cover them up," the magician said. The audience member did as the magician asked.


Then, the magician turned around and said, "Thank you for your help. Now I'll take away the remaining nine coins." 
"Now it's time to witness a miracle! I can use my magic to see whether the coin under the lid is heads or tails." In the end, the magician successfully guessed that the coin was tails. 
Then the magician invited several audience members up on stage, and he was able to guess the coin's orientation every time.
Were you amazed by the magician's "eyesight"? Perhaps you think the lid was specially made, the coins were specially made, or the magician used complex mathematical methods, but actually, the secret of this magic trick is very simple, using elementary school math: odd number + -odd number = even number; even number + -even number = even number; odd number + -even number = odd number.
Throughout the magic trick, the magician needs to remember three odd and even numbers
: (1) when the coins are first scattered on the table, secretly remember whether there are an odd or even number of coins facing up (e.g., 6 coins facing up in the picture);
(2) whether the last digit of the phone number given by the audience is odd or even (e.g., 3 is odd); and
(3) when collecting the last 9 coins, secretly count how many coins are facing up and whether the number is odd or even.
Once the magician knows whether the last digit of the coin given by the audience is odd or even, if the digit is odd, then regardless of whether the audience flips the coins from heads to tails or vice versa, and no matter how many coins are flipped, the total number of flipped coins will always be odd. Therefore, if there were an odd number of coins heads initially, there will eventually be an even number of heads (as shown in the image above, there will always be an odd number of heads). Conversely, if an even number of coins are flipped, then if there were an odd number of coins heads initially, there will still be an odd number of heads, and if an even number, there will still be an even number. Based on this calculation, the magician can then compare the number of odd and even heads among the nine coins collected to deduce whether the coin under the lid is heads or tails (in the image, there are five heads at the end, which is already an odd number, so the coin under the lid must be tails).
In fact, the simple principle of numerical parity can be used not only as a trick to confuse the audience in magic, but also has many practical applications.
For example, in digital communication, seven binary digits, such as 0010101, can represent a number, letter, or symbol. These seven binary digits can be seen as seven coins; heads is 1, tails is 0. Errors may occur during the transmission of this string of digital information. The receiving party has methods to check for errors, and parity checking, similar to this magic trick, is one of the simplest methods.
When the transmitting party transmits these 7 data (or 7 coins), an extra 1 or 0 is added (1 indicates that there are an odd number of 1s in these 7 numbers, equivalent to an odd number of coins facing up, and 0 indicates that there are an even number of 1s). This is called a check bit. When the receiving party receives these 8 binary data, it will check whether there are indeed an odd number of 1s or an even number of 1s in the first 7 digits. If it does not match the check bit, it means that there was an error in the transmission of this information. Some coins have been "flipped," for example, 1 is interfered with by noise and becomes 0, or 0 is interfered with by noise and becomes 1.
However, as you might expect, this error-detection method has flaws. Like a coin toss, if an odd number of coins are flipped, meaning an odd number of errors occur in the seven digits, the error can be detected by checking the final received result. However, errors in an even number of digits cannot be detected. But real-world communication systems need a certain level of accuracy. The probability of one "coin" being flipped is already low, the probability of two "coins" being flipped simultaneously is even lower, and three or more are almost impossible. Therefore, this parity check method, which can detect errors in a single digit, is still very useful.
You might not expect that the simple principle of adding and subtracting odd and even numbers can be so interesting.