Problem of the Day
A new programming or logic puzzle every Mon-Fri

5 Card Trick

Here's a fun problem to round out our week. We'll even learn a magic trick too!

A magician shuffles a regular 52 card deck and gives them a spectator to pick 5 random cards. The spectator does so and gives the 5 cards back to the magician. The magician then picks a card and gives it back to the spectator to keep a secret. The magician then arranges the 4 remaining cards and gives them to his partner. His partner looks at the 4 cards and exclaims the exact card the spectator is holding. How is this possible?

Enjoy your weekend!

Permalink: http://problemotd.com/problem/5-card-trick/

Comments:

  • David - 8 years, 8 months ago

    After a while, I think I have a possible solution to this. Magicians always have arrangements with assistants. In this case it is an encoding scheme. First they establish a suit order, as that takes a little more planning. Lets say alphabetical order. This will also be useful for a tie breaker I will get to. Second we establish a bit order, after all, merely arranging the cards could also mean flipping some upside down. This will allow for 4 bit encoding of the number, which is more than enough, and positional encoding of the suit. Lets say you wanted to encode the Jack of Hearts. Your four cards are the 2 of Spades, the 2 of Diamonds, the 5 of Clubs, and the 10 of Clubs. To tell the suit, you move the "least" card (2 of Diamonds) to the hearts positions (Using the other sorted cards as dividers). In this case, the second position, as in the above list. Then flip the 2 of Diamonds face down for 0, giving you the bits 1011, which is 11.

    reply permalink

Content curated by @MaxBurstein