Skip to main content
Codepiko
TR
All activities

To save a PDF, choose "Save as PDF" as the destination in the print window.

Error detection: parity magic

The big idea

Data can get damaged in cables, over wireless or on a disk: a 1 turns into a 0. By adding a few extra bits, a computer notices the damage, and sometimes even finds and fixes it. These extra bits are called parity bits.

Where do we meet it?

The last digit of a barcode or an ID number, a QR code that still scans when part of it is dirty, and photos arriving from space without damage all rely on the same idea.

40 minutes in classFor teachers

  1. 8 minGetting attentionA magic showA pupil lays out a random 5 × 5 grid on the board with magnetic or sticky cards. Say “to make it harder” and add a row and a column (really, the parity cards). Turn your back; a pupil flips one card; find it. Do not say how.
  2. 10 minLessonFind the secret togetherRepeat the show twice. Ask pupils to count the coloured cards in the rows and columns. When they notice every row and column is even, write the secret on the board.
  3. 14 minLessonOn paper and on screenPairs fill in the “Card magician” sheet, then do the magic in the Parity Magician game. In classes with cards, pairs can perform the trick for each other.
  4. 8 minAssessmentBarcode detectiveShow a product’s barcode and say that its last digit is a “parity card” too. Exit card: “What can the magician do if two cards are flipped?”

Codepiko · Computer science: Error detection: parity magic

Card magician

Goal: Use added extra information to find damaged data.

Time: 30 min · You need: Pencil; for class play, 36 cards coloured on one side

Name:
Class:
Date:

1. Add the magic cards

Every row and every column must have an even number of coloured squares. Fill in the right-hand column and the bottom row to make this true: colour a square if needed, leave it empty if not. Do not forget the corner square.

2. Which card was flipped?

Magic cards were added to this grid, then one card was flipped. Find the row and the column with an odd number of coloured squares. The flipped card is where they cross; circle it.

3. Think

Write short answers.

How did the magician find the flipped card? Explain in your own words.

What would happen if two cards were flipped?

codepiko.com