OER.ai

← Error Detection (Parity Magic Trick)

Grades 4–5 reading level

Error Detection (Parity Magic Trick)

Adapted with AI from the original open resource by CS Unplugged. Nothing is invented — only the reading level changes.

Activity 4

Card Flip Magic—Finding and Fixing Mistakes

Summary

When information is saved on a computer disk or sent from one computer to another, we usually expect it to stay exactly the same. But sometimes something goes wrong, and the information gets changed by accident. This activity uses a magic trick to show how we can find out when information has been changed—and how to fix it.

What You'll Learn

  • Counting
  • Recognizing odd and even numbers

Ages

9 years and up

What You Need

A set of 36 "fridge magnet" cards that are colored on only one side. For the demonstration, a metal board (like a whiteboard) works great. Each pair of students will also need 36 matching cards, colored on one side only.


The "Magic Trick" Demonstration

Here's your chance to be a magician!

You'll need a pile of matching two-sided cards. You can make your own by cutting up a large piece of card colored on only one side. For a demonstration, flat magnetic cards with a different color on each side work best—fridge magnets are perfect.

Step 1: Choose a student to lay out the cards in a 5×5 square (5 rows and 5 columns), with a random mix of colored and blank sides showing.

Then casually add one more row and one more column, saying it's "just to make it a bit harder."

These extra cards are actually the secret to the trick! You must place them carefully so that every row and every column has an even number of colored cards.

Step 2: Cover your eyes while a student flips just one card over. Now, whichever row and column contain that flipped card will have an odd number of colored cards. That's how you can tell which card was changed!

Can your students figure out how the trick works?


Teach the Trick to Your Students

  1. Working in pairs, students lay out their cards in a 5×5 grid.
  2. Count the colored cards in each row and column. Is the number odd or even? (Remember, 0 counts as an even number!)
  3. Add a sixth card to each row so that every row has an even number of colored cards. This extra card is called a parity card—it helps check for mistakes.
  4. Add a sixth row along the bottom so that every column also has an even number of colored cards.
  5. Now flip one card. What happens to its row and column? (They will now have an odd number of colored cards!) This shows how parity cards can reveal when a mistake has happened.
  6. Take turns performing the trick for each other.

Extension Activities

  1. Try new objects. Anything with two possible states works—like playing cards, coins (heads or tails), or cards marked with 0s and 1s (like the binary number system computers use).
  1. What if you flip two or more cards? It's not always possible to know exactly which two cards were flipped, but you can tell that something changed. Usually you can narrow it down to one of two possible pairs. If four cards are flipped, sometimes all the parity cards will look correct—meaning the mistake could go unnoticed!
  1. Think about the bottom-right card. If you pick it to make its column correct, will it also make its row correct? (Yes—always!)
  1. What about odd parity? In our activity, we used even parity (an even number of colored cards). You can also design a system using odd parity. But the bottom-right corner card will only work correctly for both its row and column if the number of rows and columns are both even, or both odd. For example, a 5×9 grid or a 4×6 grid will work, but a 3×4 grid won't.

A Real-Life Example for Experts!

This same idea for checking mistakes is used with book codes. Every published book has a ten-digit code, usually printed on the back cover. This is called an ISBN (International Standard Book Number). The tenth digit is a special check digit—just like the parity cards in our activity!

This means that when you order a book using its ISBN, the publisher can check whether you typed it correctly, using something called a checksum. That way, you won't accidentally receive the wrong book!

Here's how to calculate the checksum:

Multiply the first digit by 10, the second digit by 9, the third by 8, and so on, all the way down to the ninth digit multiplied by 2. Then add up all these results.

Example: For the ISBN 0-13-911991-4:

(0 × 10) + (1 × 9) + (3 × 8) + (9 × 7) + (1 × 6) + (1 × 5) + (9 × 4) + (9 × 3) + (1 × 2) = 172

Next, divide your answer by 11 and find the remainder:

172 ÷ 11 = 15 remainder 7

If the remainder is 0, the checksum is 0. Otherwise, subtract the remainder from 11:

11 – 7 = 4

Now check: is this the same as the last digit of the ISBN? Yes, it matches!

If the last digit hadn't been a 4, we would know a mistake had been made somewhere.

Sometimes the checksum calculation gives you the value 10, which can't be written as a single digit. In that case, the letter X is used instead.

Grocery store barcodes (called UPC codes) use a similar idea, but with a different formula for calculating the check digit. If a barcode is scanned incorrectly, the final digit won't match what it should be. That's why the scanner beeps, telling the cashier to scan it again!


Check That Book!

Detective Blockbuster Book Tracking Service, Inc.

We find and check ISBN checksums for a small fee. Join our agency—look in your classroom or library for real ISBN codes. Are their checksums correct?

Sometimes mistakes happen. Common errors include:

  • A digit's value is changed
  • Two digits next to each other are swapped
  • A digit is added by mistake
  • A digit is left out

Can you find a book with the letter X as its checksum (meaning the checksum equals 10)? It shouldn't be too hard—about 1 out of every 11 books should have one!

What kinds of errors might slip past without being caught? Can you change one digit and still get the same checksum? What if you swap two digits (a common typing mistake)?


What's It All About?

Imagine you're depositing $10 in cash at the bank. The bank teller types in the amount, and it gets sent to a central computer. But what if some interference on the line accidentally changes the amount from $10 to $1,000? That's not a problem for you—but it's a big problem for the bank!

This is why it's so important to catch errors in information that's being sent electronically. A computer receiving data needs to check that it hasn't been corrupted by electrical interference along the way. Sometimes, if an error is found, the original information can just be sent again. But this isn't always possible—for example, if a disk or tape has been damaged by magnetism, heat, or physical harm.

Think about information sent from a space probe exploring deep space. It would take a very long time to wait for the data to be resent if there was an error! (In fact, it takes just over half an hour for a radio signal to travel from Jupiter to Earth, even at its closest distance!)

That's why we need two things: error detection (recognizing when data has been changed) and error correction (figuring out what the original data was supposed to be).

Computers actually use the same method as our card-flipping game! By arranging bits (the smallest pieces of computer data) into imaginary rows and columns, and adding parity bits to each row and column, a computer can not only detect that an error occurred—it can pinpoint exactly where the error is. The incorrect bit can then be switched back to its correct value. That's error correction in action!

Of course, real computers often use more advanced systems that can detect and fix multiple errors at once. In fact, a large portion of a computer's hard disk is set aside just for correcting errors, so it keeps working reliably even if parts of the disk get damaged. These advanced systems are closely related to the parity idea you just learned!

And here's a joke to finish—it's even funnier once you've done this activity:

Q: What do you call this: "Pieces of nine, pieces of nine"?
A: A parroty error!


Solutions and Hints

Errors that would slip through undetected are ones where one digit increases while another decreases by the same amount—since the total sum might end up looking the same, even though the number is wrong.

Original licensed under CC BY-NC-SA 4.0. This adaptation is provided free by OER.ai.