Take the First Right
"Take the first right" is what people say when they give directions. Here, the dog walks along a path with openings on both sides. It should turn into the first opening on its right and follow that path to the goal. The first opening on the right is in a different place on each map, and more openings come after it.
That's another job for a loop with not:
Repeat whilenotpath to the rightMove forward
Turn right ↻
The dog walks as long as there's no path to its right, and stops at the first one. Openings on its left don't matter: it only checks its right. On the third map, the dog faces right on the screen, so its right is down the screen.
On the second map, the opening is right next to the dog where it starts. Then the loop makes no pass at all: the condition is false before the first pass, so the dog doesn't take a single step and turns right straight away. That's correct. Repeat while checks its condition before every pass, the first one too.
And why not an If inside Repeat until at the goal: if there's a path to the right, turn right, then move forward? That If asks again on every pass, so the dog would turn into every opening on its right, even those it should walk past. Try it and watch what the dog does on the first map. The loop with not stops asking at the first opening.
Instructions
- 1
Get the dog to the goal on all three maps: take the first path to the right and follow it to the goal.
- 2
Use at most 8 blocks.