Repeating Moves

There are stairs in front of the dog. Trace the path with your finger and describe it in words: "Step up, turn right, step right, turn left. Step up, turn right, step right, turn left. Step up…"

Can you hear it? The same four moves repeat over and over:

  1. Move forward
  2. Turn right ↻
  3. Move forward
  4. Turn left ↺

Something that repeats in a task is called a pattern. Spotting patterns is a big part of a programmer's work: wherever there's a pattern, the program can be made shorter.

In this exercise, though, you won't shorten anything yet. Build the whole program block by block. When you're done, look at how long it is and imagine there were a hundred stairs. In the next exercise, you'll learn a smarter way.

Instructions

Climb the stairs to the goal. On the last stair, you don't need to turn left.

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

1/8