An algorithm is a precise set of steps that solves a problem. The best way to teach this to a child is also the messiest: ask them to give instructions for making a sandwich, and then follow them exactly.
What you need
- Bread, a spread (butter, jam or something else easy), a butter knife and a plate.
- A pen and paper.
- A sense of humour.
The activity
Step 1: write the algorithm
Ask your child to write, step by step, how to make a sandwich. Don't give hints. Typical attempts: "Put the jam on the bread. Put the bread together. Eat it."
Step 2: become the robot
You are now a robot with no common sense. You do exactly what the instructions say and nothing more.
- "Put the jam on the bread" → you place the closed jar on top of the loaf.
- "Open the bread" → you look puzzled: which bread? How?
- "Spread jam" → you wave the knife with no jam on it.
Keep a straight face. It's funnier that way.
Step 3: find the bugs
Each time the robot does something silly, ask: "What was missing from the instructions?" Your child edits them: open the bag, take out two slices, put them on the plate, open the jar...
Step 4: run it again
Follow the improved version. Repeat until a sandwich appears.
What your child learns
- Precision matters. Computers do only what they're told.
- Order matters. Jam before bread doesn't work.
- Debugging is normal. Finding and fixing a problem is part of the process.
- Hidden assumptions. We skip steps because we know them. A computer doesn't.
Make it harder
- Add a condition: "If the jar is empty, use a different one."
- Add a loop: "Spread until the whole slice is covered."
- Swap roles: your child becomes the robot, and you write the instructions (deliberately a bit ambiguous).
- Use a time limit. How few steps can make a sandwich?
Link it to real coding
Show your child a short program afterwards. In Python, steps run in order too:
print("Open the bag")
print("Take out two slices")
print("Spread the jam")The computer follows each line in order, just like the sandwich robot.
Other activities with the same idea
- Directions to get a toy through a maze.
- A dance routine written in arrows.
- Brushing teeth in exactly the right order.
For more, see coding without a computer and the four pillars of computational thinking.