# “Mind Reading” Trick — A CoderDojo Tutorial

Apr 1, 2017 · 2 min read

One of our favorite ways to impress our friends is with a trick that seems like you must be using magic to read someone’s mind — but it’s actually just computer science! The secret to the trick is based on the way that computers store information and correct errors.

To see the trick performed, check out this video:

Looks like magic, right? Well, like the video was hinting, it’s all about binary digits (bits), the zeroes and ones computers use to store information.

The next video will explain how it’s done:

If it went by too fast, here’s a review of the steps in doing the trick:
1. Lay out a 5x5 grid, with some cards face up and some face down (or let your audience do it for you, so they know you don’t have the pattern memorized!).
2. Tell them you need to make it harder by adding even more cards. Secretly, though…
3. Count how many cards are face up in the first row. Is it an even or odd number? (Remember, zero is even).
4. Add a sixth card to that column, making sure that an even number of cards are face up.
5. Repeat steps 3 and 4 for each row and column, so that you have a 6x6 grid, and every row and column has an even number of cards that are face up.
6. Now, for the magic: have your audience flip one card while your back is turned. Then turn around. Count up the cards — in which row and column do you now see an odd number of cards that are face up? Where that row and column intersect is the card that’s been flipped.

Got it? Now, grab a deck of cards and try it for yourself. It takes some practice to lay down the extra row — called “parity bits” — without your audience being able to tell what you’re doing. Keep trying, though, and then go impress your friends and family!

Want to know more about how computers use parity? Check out a quick reading about a real-world example!

Written by

## Eileen King

#### Minnesota educator primarily using Medium as a publishing platform for coding tutorials | nfldcoderdojo.org | #cs4all | #mncodes

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just \$5/month. Upgrade