Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

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

  1. 1

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

Back

1/11

  1. 1. Repeating Moves
  2. 2. Loops
  3. 3. Stairs
  4. 4. After the Loop
  5. 5. Quiz: Pass by Pass
  6. 6. A Bone on Every Tile
  7. 7. Around the Flower Bed
  8. 8. A Loop in a Loop
  9. 9. A Bug in a Loop
  10. 10. Quiz: A Bug in a Nested Loop
  11. 11. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.