AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Fewer steps, less time

Week 28 · Unit 12: Be a problem solver · 3 lessons
2

Counting the seconds

Computing 5: Unit 12, pp. 159–170
GoalWork out how long a route takes when forward moves and turns cost different times, and pick the quickest route.
New words
route · the path that something takes from the start to the endturn · a quarter turn to the left or to the right on the spottime cost · the number of seconds that a step takesfloor robot · a small robot that follows commands on the floor
Explanation

A floor robot follows commands one at a time. Each command takes some time. In this lesson a forward move takes 2 seconds, and a left or right turn takes 3 seconds. To find the time of a route, count the forward moves and the turns. Then work out forwards × 2 + turns × 3. Two routes can end at the same square but take different times. The route with fewer turns is often quicker, even when it is not shorter. An efficient algorithm is the one with the lowest total time.

CommandTime
F (forward one square)2 seconds
L (turn left)3 seconds
R (turn right)3 seconds
Worked examples
A
The robot starts at the bottom-left square, facing up. It must reach the flower. Route A: F, F, R, F, F, F. It has 5 forwards and 1 turn, so the time is 5 × 2 + 1 × 3 = 13 seconds.
A
Route B goes up and across in a zigzag: F, R, F, L, F, R, F, F. It has 5 forwards and 3 turns, so the time is 5 × 2 + 3 × 3 = 19 seconds. Route B ends at the same flower, but it takes 6 seconds longer.
RouteForwardsTurnsTime
A: F F R F F F5113 s
C: R F F F L F F5216 s
B: F R F L F R F F5319 s
Here are three routes to the flower. All of them use 5 forward moves, but the turns are different. The quickest route is the one with the fewest turns.
Class activity

Floor robot (3 players, chalk or tape, a paper cup as the flower). Mark a grid of squares 5 across and 4 high. One player is the robot and follows spoken commands: F, L or R. The caller says the commands for a route from the start to the cup. A timekeeper adds 2 seconds for each F and 3 seconds for each turn on a score sheet. Try three different routes to the cup. Which one is quickest? Does the shortest-looking route always win?

Practice
1
The robot starts at the top-left square, facing right. Work out the time of this command list: F, F, R, F, L, F, F, F. Forward takes 2 seconds and a turn takes 3 seconds.
2
Route P has 7 forwards and 1 turn. Route Q has 5 forwards and 4 turns. Which route is quicker? Show the times.
RouteForwardsTurns
P71
Q54
3
This route is a staircase and takes 17 seconds. Write a faster list of commands that ends on the flower. How long does yours take?
A
4
Why is the route that looks shortest on the grid not always the quickest?