This is a magic trick performed by two magicians, A and B, with one regular, shuffled deck of 52 cards. A asks a member of the audience to randomly select 5 cards out of a deck. the audience member  who we will refer to as C from here on  then hands the 5 cards back to magician A. After looking at the 5 cards, A picks one of the 5 cards and gives it back to C. A then arranges the other four cards in some way, and gives those 4 cards face down, in a neat pile, to B. B looks at these 4 cards and then determines what card is in C's hand (the missing 5th card). How is this trick done?

Note 1: There's no secretive message communication in the solution, like encoded speech or ninja hand signals or ESP or whatever ... the only communication between the two magicians is in the logic of the 4 cards transferred from A to B. Think of these magicians as mathematicians.
Note 2: This magic trick is originally credited to magician and mathematician Fitch Cheney.
From any set of 5 cards from a standard 52card deck, one suit will have at least 2 cards represented. If the two cards of the suit are set aside, one to be returned to C, the other three cards can then be arranged in a prearranged manner to encode a number, inclusively, between 1 and 6.
Arranging any one standard suit in a circle, one can see that one of any two cards of one suit will be within six cards of the other. Thus, passing the card that is within six cards of the other to C the other four cards can be arranged to encode the identity of the card.
For example, say the 5 cards selected were the 3 of Diamonds, 7 of Spades, 7 Hearts, Jack of Diamonds, and 10 of Clubs. In counting where the cards are prearranged in clockwise fashion as Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen,King...returning back to the Ace, 2, 3, etc.. It can be seen that, though the Jack is more than six cards past the 3, the 3 is only 5 cards past the Jack. Therefore, the 3 is returned to C, and the other 3 cards are arranged to encode a value 5. This can be easily done by preassigning the value of each card by rank and suit, and then arranging the 3 cards with one of the 3!=6 permutations:
 LowMiddleHigh
 LowHighMiddle
 MiddleLowHigh
 MiddleHighLow
 HighLowMiddle
 HighMiddleLow
In the example, with the 3 of Diamonds returned to C, the other 4 cards may have been arranged with the Jack of Diamonds on top, followed by 10 of Clubs, 7 of Hearts, 7 of Spades where the Heart is considered of lower value than the Spades where they have the same rank. The arrangement of the last 3, HighLowMiddle, indicates the card sought is virtually placed 5 after the first card, the Jack  i.e., the 3; and, as the Jack is a diamond, the card passed is also a Diamond.
The arrangement of the cards do not need be as explained, nor the assignment to the permutations, yet A and B do need to prearrange how they will address these. The "suitdesignating" card might, for example, be set as the third card in the pile.

Posted by Dej Mar
on 20090529 18:54:43 