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.

zhiwo

By zhiwo

0 0 vote
Article Rating
Subscribe
Notify of
guest
11 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
helpmekim
7 months ago

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.

heloword
7 months ago

Code 52 cards into 0-51, draw five cards, sort them from small to large, calculate the sum of the five cards and then modulo 5, calculate s, then hide the information of the corresponding card of s, send the other 4 cards to another person Calculate the sum of these four cards and guess the concealed value below. Since s has been fixed, the actual concealed value must not exceed 10, so just encode the order of the four cards in advance (4!>10) , Specifically, a solution c is obtained such that the sum modulus of it and the other four is equal to the number of these four numbers less than c. This method can be extended to the case of 124 cards. If there are more than 124 cards, there is no way to always guess the 5th card correctly.

helpyme
7 months ago

I remember watching this magic video. Li Si Guai, Zhang San showed his cards. Five cards, at least two of which must be of the same suit. Assuming that the cards in the third hand are Ace of Hearts, 2 of Hearts, 5 of Spades, 8 of Clubs, and 10 of Squares, then the hidden cards of the three must be of the same suit, and the first card displayed must be of the same suit as the hidden card. The cards are of the same suit. Therefore, Zhang Sanzang must be a heart. In this way, as long as the first card shown by Zhang San is a heart, Li Si knows that there are 12 cards left to guess. Then the remaining three cards can be calculated and counted according to the placement position and placement order. For example, putting on the top is adding, putting on the bottom is subtracting, overlapping is dividing, and putting diagonally is multiplying. If one formula can get the result, you can put other cards farther. Assuming that the hidden is the 2 of hearts, the Ace of hearts is displayed first, and Li Si knows that it is a heart. Then use 5,8,10 three cards plus A, and just list out a formula. For example, divide 10 by 5, put it on top of each other, and put 8 next to it. Of course, there may be other more convenient methods. If what I said is wrong, I hope you guys can correct me.

sina156
7 months ago

The method of high praise is the same, I am mentioning another different method. This method is simpler and more convenient, and does not require too much computing power. 1. Let’s formulate a strategy first. The size of different digital cards is the larger the number, and the k is greater than 8. The same suit of cards is more than square, greater than spades, and greater than clubs 2. Five There must be two cards of the same suit. Choose one of them as the fifth hidden card. 3. The first card shows the other card of the same suit, and then you can tell the opponent what the hidden card is. 4. Put the card Placed in a certain order according to size, 1234 represents A, 1243 represents 2, such a combination has 4*3*2, which is 24 combinations, which means 1-13 is more than enough. 5. Put the cards in sequence, and the observer only needs to look at the first. What is the color of the card and the order of the last four cards to know what the hidden cards are. For example, the card I draw is 1.8.10 of hearts, 2. of spades, 2. squares of 7 and I choose to leave 1 of hearts. , And then sort the remaining cards, 2.7.8.10, which means sorting 1234, first put 8 of hearts to indicate the suit of hearts, and when the order is 2.7.8.10, it means the number is 1. You can guess the Aces of Hearts

yahoo898
7 months ago

Yes, there is a magic that changes like this. First of all, the drawer principle, five cards must have at least two of the same suit, and we will use this suit as the bottom card. Then, for the remaining three cards, we can use a certain convention to indicate their big, medium and small, such as spades> hearts> clubs> squares, and then K>Q>J>10>……2>A. By the way, let’s make an agreement again, the arrangement of big, middle and small means +6, the middle size means +5, the medium size → +4, the medium small big → +3, the small big medium → +2, the small medium big → +1 back to the first two cards, If one is A, then according to the above agreement, the other one is 234567, we can all show it, right? (First show an Ace of Hearts, and then show the big, medium and small, then it means that the bottom card of the puzzle is 7 of hearts, and the rest can be deduced by analogy.) So what if the bottom card of the puzzle is 8 of hearts? The next step is the magic operation! Let’s show the 8 of Hearts first! 8+6=14, and subtract 13 again, which is the Ace of the mystery. This kind of operation can solve 6 cards (8, 9, 10, J, Q, K), and there are still… well, no one left, all covered. perfect.

leexin
7 months ago

I thought this magic used mathematics, but it was still a good magic work. I didn’t expect someone to use it for interview questions. The core principles are the drawer principle, permutation and combination, and mod addition. Others have already explained it once, so I won’t write it in detail, so let’s take a look at the show! By the way, if you analyze it from the perspective of pure information theory, there is only log4! = log24 bit information, which is not enough to encode a playing card. But because you can choose which card to guess, under this agreement, it is equivalent to reducing the degree of confusion to a certain extent, making the plan theoretically feasible. Also, the order of the title refers to the order of the card stack, but the order of placing and removing should be fixed from left to right. If this place can introduce the transformation of information, then the magic can be even more powerful.

greatword
7 months ago

Many people have already answered. I also try if I can make it clear. 5 cards, 4 suits at most, there must be at least two cards of the same suit. Regard A as the value 1, JQK is 11, 12, 13 (the same below). Take out two cards of the same suit. If the difference is not greater than 6, hide the card with the smaller number; otherwise, hide the card with the larger number. And another card of the same suit is shown as the first card. In this way, the value of the hidden card is subtracted from the first revealed card, and if the score is negative, 13 is added. This number must be between 1 and 6. There are 3 cards left, one size, the bigger the number is, the same number, spades>hearts>diamonds> clubs. The second, third, and fourth cards are displayed in the following order: small, medium, large=1, small, large, medium=2, medium, small, large=3, medium, large=4, large, medium=5, large, medium, and small,=6. In the following, the player who reads the cards will obtain a number from 1 to 6 according to the order of the second, third, and fourth displayed cards, using the same method as above. Then add the number of the first card, and subtract 13 if it is greater than 13, and the result is the value of the hidden card. The suit of the hidden card is the suit of the first card displayed.

loveyou
7 months ago

I was entangled in this problem and couldn’t solve it terribly. It wasted a lot of time for memorizing words, but there was still no good way to use pen and paper, so I can only briefly talk about the idea: abstract the problem a bit: pay attention to this The proposition is stronger than the original question, because each poker card in the original question is different, so the mapping m constructed by Gao Zan can map the last three variables to 1-6. After allowing repetition, no matter how you change it All are useless, but in fact, the entire system does not have much more information than the original system, so this problem is also likely to be solved. (It should be noted that this is not an algebraic problem. Although groups are used to represent abstract elements, there is neither addition nor homomorphism. It is true that sets can be used directly, and the structure of groups is not required at all.) A simple translation: m It is a mapping from a 52^4 element to 52 elements, so there are a total of 52^(52^4) kinds. This kind of mapping can find an arrangement for any quintuple, so that the last number is the front The result of a certain arrangement of four numbers being mapped by m. Except for the method of constructing and directly giving such an m (after allowing the repetition of playing cards, I think it should be difficult to find manpower). The first idea I think is to use a similar sieve method to remove all unsatisfactory requirements. And then explain that the number of mappings removed is less than 52^(52^4). Not surprisingly, this method is directly GG, and the inequality step is not even used; the second idea is that the program solution method is as follows: First consider the node set A composed of all 52^4 elements, and then consider the node set B composed of all 52^5 elements, and finally find the map from A to B. Since the problem requires that for each node w in B, the required mapping can map four of them to the fifth, so the mapping must be mapped from a subset of w in node set A to w. In order to filter the map, All these nodes are connected. Doing this for all w, we get a bipartite graph G=(A,B,E), the required map must map the point a of A to b along the existing edge e, considering that this is a mapping, in fact It is to seek the maximum distribution of G. If the maximum allocation is a full allocation, there is such a map. And the Hungarian algorithm for maximum distribution can find the maximum distribution from A to B, remove the a component of b corresponding to a, and get the final mapping. In fact, because the scale of the numbers is too large, the bipartite graph is given at the beginning, and the edge set is relatively sparse, about 52^5*5! , So it is not recommended to use adjacency matrix. Then the time cost is about 52^5*5! *52^4, it can still be a whole. If there is a complete allocation, then you can find such a mapping map, which maps from a set of 52^4 elements to a set of 52 elements, which has the requirements of the problem Nature. If you save it in a text file, it only takes about 73Mb, and the memory is only about 25 copies of “A Hundred Years of Solitude” or 10 copies of “A Dream of Red Mansions”. When you discuss with your friends, use this mapping and memorize it, you can use it to perform magic tricks! Why do you ask me what’s the use of this? When this deck of playing cards has a king or a king or becomes several decks of cards, others can’t perform magic tricks, but you can still do it. In this way, your magic surpasses the b-frame of others. (I am really not good at code, it is recommended to implement and export a password book by myself)

strongman
7 months ago

In fact, there is a relatively simple scheme. Two of the five cards must be of the same suit, so one is reserved as a hidden card. 1. Put another card of the same suit directly face up to determine the suit. 2. Place the remaining cards in a way of 1 on the front side and 0 on the back side to form a binary number to represent the size of the card. The card has a maximum of 13, and does not include 0. The 4-digit binary can reach 15, and the size of the card does not include zero, so it must be 1. On the front of the first suit, just indicate 1.

stockin
7 months ago

The strategy is that the four cards are divided into 1+3. The first card has a fixed suit and its number is the base value; the last three cards get an offset of 0-5 according to the order of the big, medium and small, and add it to the previous base value. The number of five cards, if the sum after adding the base value is greater than 13, divide by 13 and take the remainder as the number. Specific operation method: at least two of the five cards are of the same suit, so first pick out two cards of the same suit. Find the difference between the numbers of the two cards (large reduction), if the difference is less than or equal to 5, then the card with the lower number is selected as the first card, offset = difference; if the difference is greater than 5, then the card with the higher number is selected , Offset = (13-difference). The other card is hidden. The first card has been determined. At this time, there are three cards left, and the 52 cards are coded 1-52 respectively. Here, suppose the order is hearts> squares> spades> clubs, then there are 6 kinds of permutations and combinations of these three cards, corresponding to 0 respectively. -5. Assumptions: small, medium, large 0, small, large, medium 1, medium, small, large 2, medium, 3, large, medium 4, and large, medium, small 5. Arrange the three cards according to the offset calculated before. The following specific examples, for example, the five cards are K of Spades, 5 of Hearts, 7 of Clubs, Square J, and Ace of Spades. The first step is to choose the king of spades and the ace of spades with the same suit. Because the difference is 12, the first card chooses the king of spades, and the offset is 13-12 = 1. The ace of spades is a hidden card. The code of Heart 5 is 44, the code of Plum 7 is 7, and the code of Square J is 37. The code corresponding to the offset 1 is small, big and medium, so the order of the second, third, and fourth cards is 7 clubs, 5 hearts, and 7 squares. When decoding, the offset of 1 is obtained in the order of two, three, and four card sizes, which is added to the base value of 13 to obtain 14, and divided by 13 to obtain the remainder 1. Therefore, the hidden card is the ace of spades.

11
0
Would love your thoughts, please comment.x
()
x