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

Stairs of Any Height

The stairs are back, but each map has a different number of them. The program from the Stairs exercise had a fixed number of passes, so it would only work on one of them.

You can put more than one block in a Repeat until at the goal loop, just like in a Repeat … times loop. But the dog checks whether it's at the goal only before each pass, not between the blocks inside. If it reached the goal in the middle of a pass, it would still carry out the rest of the blocks, and only then would the loop end.

Here it works out: at the end of every pass, the dog stands on the next stair, and the goal is on the last one. Think about whether that would still hold if the goal were one tile further.

Instructions

  1. 1

    Climb the stairs to the goal on all three maps.

  2. 2

    Use at most 5 blocks.

Back

2/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.