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

Summary

In this lesson, you learned that:

  • A program has to work for data you don't know in advance. That's why exercises have several maps, and the program must work on all of them.
  • Repeat until at the goal repeats its blocks until the dog is at the goal, however long the path is. It checks only before each pass, not between the blocks inside.
  • A condition, such as path ahead, is a question whose answer is true or false. It goes into the hexagonal slot of another block, and it counts as a block too.
  • Repeat while repeats its blocks as long as its condition is true. With path ahead, the dog walks to the end of a straight part, wherever that is.
  • Loops with conditions can be nested: the inner loop takes the dog to a corner, and the outer one repeats that until the goal.
  • Bugs like to hide in the first and the last pass of a loop. Sometimes a block has to go before the loop so that every pass works.
  • An endless loop never ends, because its passes don't bring it closer to the end. Every pass has to get the dog closer to the goal.

Time to practice. The path turns right at every corner, as in Corner After Corner, and this time, there's a bone in every corner.

In the next lesson, Conditions, the dog learns to make decisions, for example to pick up a bone only where there is one.

Instructions

  1. 1

    Pick up all the bones on all three maps. Each pass can start by picking up the bone in a corner, as in Bones All the Way. What does the dog have to do before the loop then?

  2. 2

    Walk to the goal.

Back

8/8

  1. 1. Repeat Until at the Goal
  2. 2. Stairs of Any Height
  3. 3. While There's a Path Ahead
  4. 4. Corner After Corner
  5. 5. Quiz: Only What's Ahead
  6. 6. Bones All the Way
  7. 7. An Endless Loop
  8. 8. Summary
Next

Try it yourself

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