← Error Detection (Parity Magic Trick)
Sub plan
Error Detection (Parity Magic Trick)
Generated from the original open resource by CS Unplugged. Built only from the resource — nothing invented. Free, no login.
Error Detection (Parity Magic Trick)
Objective
Students will learn how computers detect (and correct) errors in stored or transmitted data by using a "magic trick" based on counting odd and even numbers of coloured cards.
Materials
- Set of two-sided cards (coloured on one side only) — 36 per pair of students, plus a demonstration set
- A metal board or whiteboard for the demonstration (if using magnetic cards)
- (This resource only — no other prep needed)
Warm-up (~5 min)
- Tell students: "Today I'm a magician, and I'm going to show you a trick that computers actually use to catch mistakes!"
- Ask the class: "Is the number 0 odd or even?" (Answer: even — make sure everyone agrees, since this matters later.)
- Quickly review odd vs. even with a show of hands: call out a few small numbers (2, 3, 4, 5, 0) and have students say "odd" or "even."
Main Activity (~25 min)
- Demonstration (5 min): Choose one student to lay out cards in a 5×5 square, colour-side up or down in a random mix. Casually add one more row and one more column ("just to make it harder") — secretly choose these extra cards so that every row and every column has an even number of coloured cards showing.
- Cover your eyes and have a student flip exactly one card over anywhere in the grid.
- Uncover your eyes and "magically" find the flipped card by scanning for the row and column that now has an odd number of coloured cards — the flipped card is where that row and column meet.
- Ask the class: "Can anyone guess how I did that?" Let a few students share guesses.
- Paired practice (20 min): Have students work in pairs with their own 36 cards.
- Step 1: Lay out cards in a 5×5 square.
- Step 2: For each row and column, count the coloured cards. Say aloud whether the count is odd or even.
- Step 3: Add a 6th card to the end of each row so that every row now has an even number of coloured cards. This extra card is called a parity card.
- Step 4: Add a 6th row along the bottom so that every column also has an even number of coloured cards.
- Step 5: One partner closes their eyes while the other flips exactly one card anywhere in the grid.
- Step 6: The first partner opens their eyes and finds the odd row and odd column to identify the flipped card.
- Step 7: Partners swap roles and repeat several times.
Wrap-up / Exit Ticket (~10 min)
Ask students to answer on paper or aloud:
- What is a "parity card" and what job does it do?
- Why do we use even numbers of coloured cards instead of odd?
- In your own words, explain how you can tell which card got flipped.
- Why do computers need a way to detect errors? (Hint: think about sending data between computers or across long distances.)
If Time Remains
Ask pairs to try flipping two cards at once instead of one, then check which rows/columns become odd. Discuss as a class: Can they always tell exactly which two cards were flipped? (They may only be able to narrow it down to one of two possible pairs.) This shows that the trick can detect an error even when it can't always pinpoint it perfectly with multiple flips.
Original licensed under CC BY-NC-SA 4.0. This teaching material is provided free by OER.ai.