# Solution for Robozzle puzzle no 291 - Huh? Part 2

I want to solve Robozzle puzzle number 291 - Huh? Part 2.

You can see it raw in the image below. You need to collect the stars without falling out of the given grid. You are the rocket on top-left corner of the grid; starting point is red cell here.

You give certain commands to the rocket and it obeys them. The less command, the better. Commands for this puzzle are shown below.

Commands are displayed on right side. From top to down they are: go straight, turn left, turn right; call F1 function, call F2 function, call F3 function; change colour of the current cell to green, change colour of the current cell to blue; execute this command no matter what the colour of cell is, execute this command in red cell, execute this command in green cell and execute this command in blue cell.

Each time it starts with F1 function. If you don't call F2 function in F1 then it will not execute commands in F2. Same applies for F3; if you don't call it, it won't be executed.

Let me show you how to play this game in another easy puzzle.

This puzzle is called "Stairs." You can see the commands and given function on the bottom right corner again. They are blank. If I click on Go! nothing happens because there are no commands given in function.

Now, let's fill in the function with some necessary commands.

You can see where robot stays. It hasn't collected all the stars. Function was called but it was executed just once. Why? Because there is no iteration (or recursion) or repetition of commands.

Remember we need to collect all the stars, so let's call F1 function again at the end of commands so that it iterates (or recurses) or repeats itself.

The rocket has collected all the stars because F1 was called again at the end so that it repeatedly goes beginning when it finishes executing all the commands. At the bottom you can see what the next steps are such as turn left, go, turn right and F1. This was completed in 5 commands.

Now, hoping that you understood how to solve this puzzle I'm returning back to my puzzle in question; I was able to collect only one star in the centre (in green cell) by calling only 2 functions: F1 and F3. However, that's not enough to solve the puzzle. Remember, I needed to collect all the stars.

Now, with the image below, there is still no solution. It just does repetitious U-turn between the green cells in the centre. What I did was to turn right after red cell and colour the cell to green on the corner. I wanted to utilise those green cells on the corners when I return back from the star in the middle. I need to collect the star on the upper left corner also. But, it didn't work.

There are a lot of possible solutions for this puzzle. One way is to collect the star behind the rocket (on the upper left corner) first and then collect the star in the middle. For this one you don't need to use colour changes as far as I know because I have read the comments in that website: comments for Robozzle 291.

And there is another solution: you collect the star in the middle and colouring the corners (or just the cell near the corner, like red one was) to utilise them when returning back. I thought about colouring the cell after you turn right, so that it acts as milestone when returning back. So that you turn left after green when returning back from the middle; as you did turn right after red when going forward to the middle. It is shown below.

Still, I couldn't solve it. I have been dealing with this puzzle for more than 3 days and I think more than when a person spends more than a day or two is enough for asking help from others. There are a lot of solutions for these puzzles and they are fun. You can see my another question in this website where I got a lot of nice answers each of them being quite different: Shorter solution for Robozzle puzzle no 132 - Split. Thanks beforehand.

• Dear users, thanks for your efforts and solutions. I wish I could give you all +50 bounty. I can reward +50 bounty for only 1 user and I rewarded @Rick since he was the first one to submit the correct answer. Thank you all for your efforts. I appreciate your hard work. Feb 13, 2023 at 11:49

I've spent a couple minutes trying to figure this out.

It's a fun, nice challenge. Thanks for posting this. I've come up with this solution:

It gets the star behind the player first, then turns around again. The rest is just straight ahead and it turns right when the tile isn't blue.

• What a nice solution, Thanks sir. Turn back, go, repeat it if blue; if red then starting point of puzzle, (and I know how to do the rest). Simple yet intriguing :) Feb 9, 2023 at 15:10

And here are some variations. In both cases you turn around to get the nearby star first.

and

• More ways to solve this cool puzzle are always welcome. Feb 13, 2023 at 8:28
• Thanks for the solutions. I never thought about your first solution but I was expecting the second one. Because U-turn go and U-turn go is enough to get the star behind. And then F2 is enough to go forward and collect the star in the middle. I couldn't put it in correct commands. Thanks again for providing two different solutions. Feb 13, 2023 at 12:07

Another possible solution (turn back later):

• I was expecting this solution :) I knew that green cell was not on the corner but after just turning the corner. Because green in the middle gave it up, you can turn left after the green in the middle. Thanks for the alternative solution. Feb 13, 2023 at 11:21
• You're welcome. It looks like you were going for this kind of a solution with your attempts. I tried going back early but couldn't make it work, so went forward first. Feb 13, 2023 at 11:38