maddyhelps

Grade 5 · Printables

Code a path

Write it, test it, debug it. Part of looking closely.

All sheets

Code a path

Write it, test it, debug it · Alberta Grade 5 · maddyhelps.com

Name
Date

Write a program to take the robot from S to F without hitting a rock, using arrows and numbers — → 2 means two squares right. Test it with a finger. Then find the bug in someone else's.

SF

My program

This program has a bug: → 2, ↑ 3, → 2, ↓ 2, → 1. Which step is wrong?

How many squares long is the shortest path?

For the grown-up

Code a path

One shortest program: → 2, ↑ 2, → 2, ↓ 2, → 1 — 9 squares. The bug: the second instruction goes one square too far (↑ 3 should be ↑ 2). Other routes that avoid the rocks are fine; testing each one with a finger is the design process.

Finding someone else's bug is harder and more useful than writing a program that works first time. Every programmer spends most of their time on the second job.

Why this matters is on the looking closely page. More sheets