A deck of 52 playing cards. The dealer randomly distributes five cards to A. A can clearly show 4 of the cards after seeing the face of the card and keep one hidden card. A will proceed in a certain order when expressly stated. Which ones to keep The order of hidden cards and exposed cards is determined by A. B is a friend of A and wants to know what A’s hidden card is. Question: Can A and B pre-appoint a strategy (the display order of the 4 bright cards) so that B can guess the remaining hidden card?

This is a reasoning question that I brushed up on a foreign forum before. I don’t remember the source. Let me repeat the question and answer roughly: I met a magician, and he brought an assistant to me and turned me into a poker. magic. This is how he changed: He asked me to find a deck of playing cards by myself, there is no king of big or small, so I can make sure that this deck of cards has never been moved. Then I shuffled the cards myself, draw 5 cards at random, and handed these 5 cards to his assistant (I know what these 5 cards are). His assistant gave four of them to the magician and the other to me. After seeing the 4 cards, the magician told me the suit and size of the card in my hand. Throughout the process, the magician did not touch a card until his assistant handed him the 4 cards. And I can guarantee that the magician and assistants did not make any eye contact during the whole process, which means that the magician only inferred the content of the card in my hand based on the content of the 4 cards. But I found that the assistant exchanged the order of the other four cards before giving them to the magician. Of course I know that the magician and his assistant have agreed some operations in advance, so that the magician can deduce the card in my hand based on the 4 cards only, but these 5 cards are randomly selected by me. , No matter how the assistant exchanges the order, 4 cards can’t cover the information of 48 cards (52-4)! I can’t think of how they did it anyway. Question: What is the secret of this magic? The answer is as follows: Let me continue this story. I returned home and started to meditate. The magician knew the cards in my hand through 4 cards. No matter how he did it, he must have determined me separately. Design and size. Note that the magician’s 4 cards and the 1 card in my hand are determined by the magician’s assistant, so the assistant can choose one of the 5 cards and give it to me, and give the rest to the magician. Determine the suit: There are 4 suits of playing cards, and there are 5 cards in total. According to the pigeon nest principle (drawer principle), there must be a suit. Among these 5 cards, there are more than two cards of this suit. Then the assistant can choose this suit, give me one of them, and put the other on top of the four cards. In this way, the magician only needs to pass the suit of the top card to know the suit of the card in my hand. Determine the size: Although the 5 cards are completely random, they can determine the order of size. Remember J=11, Q=12, K=13, we stipulate that the comparison rules of two playing cards are as follows: first compare the value, the playing card with the larger value is the big card; if the value is equal, follow the order of spades>hearts> clubs >Cube. For example, 9 of spades>9 of hearts, clubs k>square k, diamonds 8>5 of spades, and so on. In this way, among the 4 cards that the assistant gave to the magician, one of them is placed on the top, and the remaining three can be arranged in different order of magnitude. We define a value for each order: small, medium, big=1, Small large medium=2, medium small large=3, medium size=4, large medium=5, large medium small=6. In this way, the magician can have any one of the 6 numbers 1-6. But there are 13 numbers in playing cards. This seems to be unsolvable, 3 cards can not determine 13 numbers anyway. I was thinking hard again, and I started to notice the card that was placed at the top. Besides helping the magician to determine the suit, does it have any other purpose? It definitely works! Otherwise it is impossible for the magician to determine the size through these three cards. Its color effect is no longer available, so only its value can be used. I started to organize the information I had: I can get one of the 6 numbers from 1-6 at will, and I record it as i; I have another random number from 1-13, which I record as j; I want to use them to determine the other A number from 1-13, I denote it as x. addition? I started to get excited, if x=i+j, then you’re done! But the happiness did not last long before it subsided, because I found that j and x are random, and the difference between them may be greater than 6, such as x=11, j=2, and it is never possible to get i+j=x because. My mind helped me. My thinking at the time was: Is there a way to keep the difference between them within 6? I looked at the clock on the wall. After 12 o’clock, the hand slowly came to 1 o’clock. . . Suddenly, my inspiration came! Since both x and j are numbers 1-13, when x-j>6, because j>1, x>7 and j<7. If x<=7 or j>=7, it is impossible for x-j>6 to exist. So we can come up with i+x>13. What is it for? We stipulate a new addition operation: when the sum of two numbers> 13, subtract 13 as the result. For example, 6+10=16>13, at this time we specify. This is the “loop addition” that I invented myself, just like a clock, after over 12, it starts from 1. To sort it out: Let x be the value of the card in my hand, j be the value of the top card in the magician’s hand, and i be the value corresponding to the sequence of the remaining three cards. The first case: when xj<=6, we can exchange the order of 3 cards and make up an i, so that i+j=x, so that the magician knows the size of the card in my hand; Two cases: when xj>6, the assistant should give me the card of j, and give x to the magician, because x must be >7 and j must be <7. At this time, we can exchange 3 cards In order to make up an i, using our cyclic addition, we can prove that when 07, give me the smaller one, also assuming the value is x, then put the larger one on top, assuming the value is j, Then use the remaining three cards to make up an i=13+xj. Because j-x>7, i can still be collected in the range of 1-6. The magician found that i+j>13. According to the rule of circular addition, subtract 13 from the value of i+j to get x. Give two examples: if the 5 cards are 5 of hearts, 8 of hearts, 3 of spades, 9 of clubs, and 7 of diamonds, the assistant finds that there are two hearts, then one of them should be given to me and the other 4 tops. Because 8-5=3<7, you can directly use 3 of spades, 9 of clubs, and 7 of diamonds to make a 3, that is, according to our previous agreement: medium, small and large = 3, then these three cards are placed in diamonds, 7 of spades 3. The order of the 9 of clubs, so that the magician knows that this represents 3, and then put the 5 of hearts on top to the magician, and the 8 of hearts for me. What the magician saw is that the 5 of hearts is on the top, so the card in my hand is hearts; the order of the next three cards is medium, small, big=3, plus the value of the top 5 of hearts=8 , No more than 13, then 8 is the size of the card in my hand, so the card in my hand is 8 of hearts. The second example: 4 of spades, Q(12) of spades, 5 of hearts, 5 of clubs, 9 of diamonds. The assistant found that there are two spades, so they should give me one of them, and put the other to 4. On the top. Because 12-4=8>7, I should give me the 4 of spades and the Q of spades on top of the 4 cards. And 4+13-12=5, so you can use Ace of Hearts, 5 of Clubs, and 9 of Diamonds to make a 5, which means that the size is 5, that is, the order is 9 of Diamonds, 5 of Clubs, 5 of Hearts, and then the spades Put the Q at the top and give it to the magician, and give me the 4 of spades. What the magician saw is that the Q of spades is on the top, so the card in my hand is spades; the order of the next three cards is medium=5, plus the value of the Q of spades on the top=5 +12=17>13, 13 should be subtracted according to the circular addition, so 17-13=4, which is the value of the card in my hand, so the card in my hand is 4 of spades.

I was asked this question during the interview, and then I got the answer after researching on the spot for half an hour. At least two of the five cards are of the same color. Choose one of them and place them at the front to determine the color. The two points of the same suit are x and y. Either, or vice versa. Because there are 13 cards in total, 13 cards are arranged in a ring, and the distance between any two different two must not exceed 6. Let me give an example here. If the two cards have 6 and K respectively, then put the K out to guess 6, K+6=6. If it is 7 and K, then put 7 out and guess K, 7+6=K. No matter what the points of the two cards of the same suit are, the relationship between x=y+a and a not exceeding 6 can always be found. For the remaining three cards, we agreed to sort by point size and suit size. It does not matter what rules are agreed upon, as long as the size relationship between the cards can be judged. The specific implementation method can be that all cards are first based on the suit ratio of the bridge cards, and the big suit is considered big. The suits and colors are arranged in the order of largest and smallest according to the point ratio. For example, spades Q> spades 2> hearts 10> square K and so on. After determining the size of the three cards, observe that the most placement order is +1 for small, medium and large, +2 for small, large and medium, and in the last case, large, medium and small +6. The relative order of the remaining three cards corresponds to a certain situation a from +1 to +6, and the corresponding operation can get x=y+a. For example: get the 2 of hearts, king of hearts and three other cards. A first shows the King of Hearts, and the three other cards are laid out in the order of relative size 132 according to the relative order determined by the agreed suit points. B sees that the first card is a K of Hearts, and confirms that the suit is a Heart of Hearts, and it is within A~6 of Hearts. Using the relative sequence 132 of the last three sets of cards, we get +2, and the K+2=2 of hearts, and the rest of the first hand is the 2 of hearts.