## A magazine where the digital world meets the real world.

# On the web

- Home
- Browse by date
- Browse by topic
- Enter the maze
- Follow our blog
- Follow us on Twitter
- Resources for teachers
- Subscribe

# In print

# What is cs4fn?

- About us
- Contact us
- Partners
- Privacy and cookies
- Copyright and contributions
- Links to other fun sites
- Complete our questionnaire, give us feedback

# Search:

# Carry on conjuring - Doing the trick

## What you need:

A pack of cards

A pen and paper to write the predication

Binary numbers and a sorting algorithm

Magical showmanship

## The set up

The trick is set up while you are doing the last part of the 21-card trick.

As you finish the 21-card trick you have 3 sets of 7 cards on the table. Two of these sets do not contain the chosen card. As you move to revealing the chosen card which is in the middle of the middle set, place the other two piles of 7 cards face up on the table to make a single discarded pile of 14 cards.

In the final set of cards you know the chosen card will be in the middle of the set (see the 21-card trick instructions). As you discard the other cards in the pile that aren't the chosen one place any two of them on the face up pile of 14 to make a pile of 16. You now secretly know the value of the 16th card in the face up pile (THE TOP ONE) - remember it!

Once the 21-card trick is done, turn over and put this stack of 16 cards on top of the pack, putting the rest underneath, so you now secretly know the value of the 16th card from the top

## Alternative (easy) set up

Alternatively, if not doing this as a follow up on the 21-card trick, you can just set the pack up so you know the value of the 16th card from the top. That's all that is important here.

## Your prediction is...

With the face down pack in front of the spectator (you know the value of card 16 from the top), write this card's value as your prediction.

## Doing the trick

Ask your spectator to cut off about half the pack. The important thing here is that they cut off more than 16 but less than 32 cards. If it looks like they haven't, ask them to replace them and cut less (or more). You can claim you don't want to take too long with the experiment (or for it to be too easy). Now follow the instructions: first card face down on remnants of the pack, next card face up on a separate pile and so on.

The final card left will the 16th card from the top of the original deck, so will match your prediction. Remind them of their free cut, the shuffle and take your deserved applause.

## Binary magic (sort of)

Why does it work? Well it's based on binary arithmetic and an algorithm for searching. The deals progressively eliminate every second card, and leave half of those that were previously left. Another way of saying that is that the remaining cards are related by 2n where the n is the deal you are doing (n is 1 for the first deal, 2 for the second and so on). Let's look at this sieving process in detail.

The original set cut from the top of the pack will be 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ... < 32 (You don't know how many cards there are but you have fixed this number of cards to be less than 32). Remember you know the value of card 16. It's your prediction. The first face down is discarded, the next kept, and so on. That means this first 'fair' deal actually just eliminates the odd position cards. Your volunteer is left with cards 2,4,6,8,10,12,14,16,18, 20, 22, 24... < 32 in the face up pile. Another way of saying that is they have cards from original positions, 2n for each n<16 (as you fixed it that 2n is less than 32 and 32=2x16).

Take this remaining set, turn them over and do the same deal again. Again you will remove every second card leaving 4,8,12,16,20, 24,... < 32. You are left with cards from original positions 4n where n<8 now (as 32=4x8). Same deal again removes every second card leaving cards 8,16,24 ... < 32, that is cards from original positions 8n where n<4 (as 32=8x4). Finally, dealing again removes every second card leaving 16 ... < 32. The deal selects cards with values 16n where n<2. Since n<2 means n must be 1, that shows we are left with card 16 alone ... and card 16 is your prediction.

## Sort of important

Binary numbers are fundamental to computer science, in part because computers use binary to represent data. There are some more interesting links too. The way computers solve problems quickly are often based on binary properties. For example one of the most efficient ways to search for data works by discarding half of the data each time, always keeping the half where the searched for thing resides, just as in our trick. It is called 'Binary search'. An algorithm called Radix Sorting also works in a similar way to sort data into order: it was used on early computer punch card machines to sort punch cards. A variation of it was also used by early computers to pull out a particular punch card from a mixed up pack of cards - just as we did for card 16. Abracadabra!