Lesson 3 · Computational Thinking
Write instructions a robot follows without asking questions.
Imagine a robot on a grid. It understands exactly four commands and nothing else:
FORWARD n — move n squares aheadLEFT — turn 90° left, staying putRIGHT — turn 90° right, staying putPICK — pick up whatever is on this squareThat's the entire language. "Go to the treasure" means nothing to it. "Head towards the door" means nothing. You must build everything you want out of those four words.
The mistake almost everyone makes on their first try: forgetting that LEFT and RIGHT don't change the robot's square. They only change which way it faces.
So to go from facing north to moving east by two squares, you need two commands: RIGHT then FORWARD 2. Write only FORWARD 2 and the robot cheerfully goes north instead — doing exactly what you said, and not at all what you meant.
The robot starts at the bottom-left of a 4×4 grid, facing north. The treasure sits two squares up and three squares right.
| Command | Where it ends up | Facing |
|---|---|---|
FORWARD 2 | Two squares up | North |
RIGHT | Same square | East |
FORWARD 3 | Three squares right | East |
PICK | Treasure collected | East |
Four commands. Notice that RIGHT costs a line but moves nothing.
Draw a 4×4 grid on paper. Mark the robot at the bottom-left facing north, and put the treasure anywhere you like. Now write the program.
Sketch the grid, place the robot at the bottom-left with a small arrow showing it faces north, and mark your treasure square. Add one obstacle square the robot must go around.
The robot faces north and runs: FORWARD 1, RIGHT, FORWARD 1, RIGHT, FORWARD 1. Which way is it now facing?
This chapter is free — open this lesson in your portal to save your answers and track progress.
Before you claim a program works, follow it yourself, literally, refusing to use what you know. This one habit will catch more of your bugs than anything else you learn this year.
The robot starts bottom-left of a 5×5 grid facing north. Treasure is at the top-right corner. One obstacle blocks the exact centre square.
Write a program that collects the treasure in as few commands as possible. State your command count, and explain why a shorter one isn't possible.