A Bug in a Loop

There's a bone on every other tile of the path. The program is almost done, but the dog only picks up one bone and doesn't reach the goal. The program has two bugs. Run it and find them.

Bugs in loops come in two kinds:

  • The wrong number of passes. The loop runs one pass more or fewer than it should. Count how many times the pattern should repeat.
  • A block in the wrong place. A block that should repeat is under the loop, so it's only carried out once. Or the other way round: a block that should be carried out once is inside the loop.

If you're not sure, watch the blocks light up: you'll see which blocks repeat and which are carried out just once. Fix the bugs one at a time: fix the first one, run the program again and see what changed.

Instructions

Fix the program so that the dog picks up all the bones.

And walks to the goal.

Start programming for free

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

Or sign up with:

8/8