Archive for the ‘Math and Magic’ Category.

A Hat Trick

My readers know that I love hat puzzles. This is why I decided to turn a number trick by Konstantin Knop (in Russian) into a hat trick.

Hat Trick. The audience has a bottomless supply of hats in ten different colors. They arrange ten people in a line and put one of the hats on each person. Then the magician’s assistant comes in and removes a hat from one of the ten people. After that, the magician appears and, abracadabra, guesses the color of the removed hat. The magician and the assistant agreed on a strategy beforehand. What is it?

Keep in mind that this trick won’t work with fewer than ten colors. As a bonus, can you explain why?

Sep 18, 2022 Correction: I meant “with fewer than ten people.”


Seven, Ace, Queen, Two, Eight, Three, Jack, Four, Nine, Five, King, Six, Ten

Seven, Ace, Queen, Two, Eight, Three, Jack, Four, Nine, Five, King, Six, Ten

To prepare for this magic trick, take all the spades out of a deck and place them in the following order: seven, ace, queen, two, eight, three, jack, four, nine, five, king, six, and ten. Turn the assembled deck face down, so that the seven is on top. Now you are ready to do the trick.

Magic trick. Transfer the top card to the bottom of your deck and deal the new top card face-up on the table. Repeat this process until all the cards are dealt. And — abracadabra — the cards are dealt in order.

I showed this trick to my grandchildren, and they decided to reproduce it. They tried to calculate where each card goes, without too much success. Then my son showed them another trick: how to arrange the cards without calculation. He started building his arranged deck from the end of the trick with all the cards in order face-up on the table with the king on top. He took the king and put it face-down into his hand. Then he repeated the following procedure until all the cards were in his hand: He took the next card from the table and put it face-down on top of the one in his hand. Then he moved the card from the bottom of his deck to the top. And — abracadabra — the cards are arranged correctly for the trick.

Next time, I should ask my grandkids to show this trick with the whole deck.

The trick with the whole deck


A Card-Dealing-Trick Sequence: Persistimis Possessiamo

Pete McCabe presented his trick, Persistimis Possessiamo, at the Gathering for Gardner in 2018.

Trick. Pete asked for two volunteers, let’s call them Alice and Bob. Bob took out his favorite card, the Queen of Spades, from the deck and put it back following Pete’s instructions. Then Alice dealt the deck alternatively into two piles, Bob’s and hers, starting with Bob’s. Alice took her pile and repeated the same process several times until only one card was left. And, abracadabra: it was Bob’s chosen Queen of Spades.

Pete McCabe is interested in scripting magic. In his blog post, Scripting Magic for Zoom, he describes ways to make sure that Bob inserts his card into the 22nd place without using sleight of hand, but rather using a theatrical script which makes the process magical rather than mathematical. The magic part is related to the fact that the number of letters in the trick title, Persistimis Possessiamo, is 22. As a result, he can do the trick on Zoom without ever touching the cards.

Once a magician knows how to manipulate the volunteer to insert the card into a specific place in the deck, the trick becomes deterministic and works on any-sized deck, as long as the magician can calculate where the card goes. We will now perform this calculation.

We denote our card-inserting sequence as a(n), where n is the size of the deck, and a(n) is the place where the card is inserted. For starters, a(2n+1) = a(2n): when the size of the deck is odd, the last card during the first deal goes to Bob, and doesn’t effect the other deals. Now, we obviously have a recursion. First, we observe that in order to end up in Alice’s pile after the first deal, Bob’s chosen card should occupy an even-numbered place. Suppose we start with 2n cards. After the first deal, Bob’s chosen card is in the place number a(2n)/2 from the bottom in Alice’s pile. That means, the card is in the place number n + 1 − a(2n)/2 from the top. This gives us an equation: a(n) = n + 1 − a(2n)/2, which is equivalent to a recursion: a(2n) = 2(n + 1 − a(n)).

Given that each element of the sequence a(n) is doubled, we are only interested in even-indexed values. Consider b(n) = a(2n) = a(2n+1). Then b(1) = 2, and the recursion for b is b(n) = 2(n + 1 − b⌊n/2⌋).

From here, we get the sequence, which is now sequence A350652 in the OEIS:

2, 2, 4, 6, 8, 6, 8, 6, 8, 6, 8, 14, 16, 14, 16, 22, 24, 22, 24, 30, 32, 30, 32, 22, 24, 22, 24, … .