- repeat 4 timesmove up
Fewer blocks
The robot likes short programs. Four move_up() lines take it up 4 squares. One loop does the same job in just 2 lines.
- repeat 5 timesmove right
One straight line, one loop
The flag is 5 squares right, in a straight line. One loop does the whole line. That is repeat 5: with move_right() inside.
- repeat 3 timesmove downrepeat 4 timesmove right
A turn starts a new loop
When the robot turns, start a new loop. This robot goes down 3, then right 4. That is two loops, one for each straight part.
- repeat 4 timesmove rightrepeat 3 timesmove up
Find the gap
Rocks block the way up. Find the gap first. Here the gap is on the right side. Go right 4, then up 3. Two loops get past the rocks.
- repeat 3 timesmove rightrepeat 2 timesmove uprepeat 3 timesmove right
Count the straight parts
Count the straight parts of the path. This path has three straight parts. So it needs 3 loops.
For parents
Goal: Your child learns to make programs shorter by using one loop for each straight line of moves.
- Ask: where does the robot turn? Each turn starts a new loop.
- Ask your child to count the lines in two programs and say which one is shorter.
- In the labs your child writes short programs with loops and fixes a loop with the wrong number. Fewer lines earn more stars.
Away from the screen: Make a path on the floor with tape that has one turn. Your child says the program, like "repeat 4: step forward, repeat 2: step left", then walks it.