I’m wondering a shorter resolution for Robozzle puzzle quantity 132, “Cut up.”
Puzzle is proven under. I’ve solved it however I am questioning shorter resolution for this and there many exist.
Mainly, the rocket has to gather stars.
You give sure instructions to the rocket and it obeys them. The much less command, the higher. Instructions for this puzzle are proven under.
Instructions are displayed on backside proper nook. From high to down they’re:
execute F1 operate,
execute F2 operate;
execute this command it doesn't matter what the color of cell is,
execute this command in purple cell and
execute this command in inexperienced cell.
Every time it begins with
F1 operate. If you happen to do not name
F2 operate in
F1 then it is not going to execute instructions in
Let me present you learn how to play this sport in one other simple puzzle.
This puzzle known as “Stairs.” You’ll be able to see the instructions and given operate on the underside proper nook once more. They’re clean. If I click on on
Go! nothing occurs as a result of there aren’t any instructions given in operate.
Now, let’s fill within the operate with some vital instructions.
You’ll be able to see the place robotic stays. It hasn’t collected all the celebs. Operate was known as however it was executed simply as soon as. Why? As a result of there isn’t a iteration (or recursion) or repetition of instructions.
Keep in mind we have to accumulate all the celebs, so let’s name
F1 operate once more on the finish of instructions in order that it iterates (or recurses) or repeats itself.
The rocket has collected all the celebs as a result of F1 was known as once more on the finish in order that it repeatedly goes starting when it finishes executing all of the instructions. On the backside you possibly can see what the following steps are reminiscent of
flip proper and
F1. This was accomplished in 5 instructions (or steps).
Now, hoping that you simply understood the basics of this puzzle let me present you my longer resolution for Robozzle puzzle quantity 132 – “Stairs”. It incorporates 11 instructions (or steps).
I screenshot it through the execution of instructions to be able to see the upcoming steps (or instructions) on backside command line. I immediately known as
F2 as a result of
F1 was very quick. In
I turned 180 diploma again,
turned 180 diploma again once more, and
stepped ahead twice. I repeated these steps so long as the cells had been blue. After blue cells I put
flip proper on inexperienced and
go straight on any color.
Mainly, I stepped again as soon as and stepped ahead twice. Repeated this motion (or recalled
F2) so long as the rocket was in blue cells. Since there have been quite a lot of blue cells, the
F2 known as itself repeatedly suspending the instructions (or steps) I entered after
flip proper on inexperienced and
go straight on any color. So far as I do know that is known as “stacks” (or “stacking”) in programming. You’ll be able to see them piled up on the command line on the backside of the picture. When the rocket arrives on the inexperienced cell it offers up calling
F2 and executes the stack or piled steps after
turns proper on the inexperienced cell and
goes straight. It ignores
flip proper on inexperienced afterwards. Why? As a result of there aren’t any inexperienced cells besides the nook.
My resolution incorporates 11 instructions (or steps). I am searching for a shorter resolution for this Robozzle “Cut up” puzzle: http://www.robozzle.com/js/play.aspx?puzzle=132.
There exist 7 command (or 7 step) resolution.
Thanks in your time and efforts beforehand!