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

Follow and fix steps

Week 1 · Unit 1: Making programs clear · 3 lessons
3

Say it in fewer steps

Computing 3: Unit 1, pp. 8–27
GoalMake an algorithm shorter by joining steps that are the same and next to each other.
New words
repeat · to do the same thing againconcise · short, with nothing extraefficient · doing a job with the fewest steps
Explanation

Look at this algorithm: clap, clap, clap, nod, nod. Some steps are the same and come one after another. We can join them: “Clap 3 times. Nod 2 times.” It does the same job, but it has 2 steps instead of 5. A short algorithm is called concise. An algorithm that does the job in the fewest steps is efficient. It is quicker to write and easier to check. Take care: you can only join steps that are the same and side by side.

Long algorithmShort algorithm
ClapClap 3 times
ClapNod 2 times
Clap
Nod
Nod
Worked examples
forwardforwardforwardforward
A floor robot is told: forward, forward, forward, forward. All four steps are the same, so we write “Forward 4 times”, or F4. Four steps become one.
LongShort
StampStamp 2 times
StampJump
JumpStamp
Stamp
Stamp, stamp, jump, stamp. Only the first two steps are side by side and the same. We write: Stamp 2 times, Jump, Stamp. The last stamp has a jump in front of it, so it cannot be joined.
An artist draws a star three times and then a heart. The long algorithm has 4 steps. The short one is: Draw star 3 times. Draw heart. That is only 2 steps.
Class activity

Shorten it (with a friend): one of you says a long list of actions with some repeats, for example “hop, hop, hop, clap, spin, spin”. The other writes it as short as possible: “Hop 3 times, clap, spin 2 times”. Then do the long list and the short list with your body. Do they look the same? Swap jobs.

Practice
1
Make this algorithm shorter: Jump, Jump, Jump, Jump, Spin.
2
A toy robot follows these six steps. Write a shorter algorithm that does the same job.
StepInstruction
1Move forward
2Move forward
3Move forward
4Turn right
5Move forward
6Move forward
3
Look at the two lists. In which list can two steps be joined? Hop, Hop, Skip or Hop, Skip, Hop.
4
The robot cards show 5 steps. Write them with only 3 steps.
forwardforwardturn rightforwardforward