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

A Path with Bones

Put together everything you know: the dog has to walk along a winding path to the goal and pick up all the bones on the way. Some of them lie on straight sections, others right at a turn.

On every pass through the loop, the dog now does two things, one after the other:

  1. It checks whether there's a bone under it, and if there is, it picks it up.
  2. It decides where to go next, just as in the last exercise.

Both parts go in the loop, one under the other. The first is a separate If block without an else part: when there's no bone, the dog does nothing and moves on to the second part.

A big program is easiest to build in parts. You can first build the loop that gets the dog to the goal, try it out, and only then add picking up the bones.

Instructions

  1. 1

    Pick up all the bones on all the maps.

  2. 2

    Walk to the goal.

Back

6/9

  1. 1. The If Block
  2. 2. If, Else
  3. 3. Which Way at the Corner?
  4. 4. Quiz: One Part per Pass
  5. 5. An If Inside an If
  6. 6. A Path with Bones
  7. 7. Quiz: A Bug in a Nested If
  8. 8. Side Trips
  9. 9. Summary
Next

Try it yourself

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