## Google doodle programming for kids solutions

Today (2017-12-04) Google published a doodle that has to do with programming for kids.

Although this is the way kids should learn how to program, the doodle is incredibly difficult and should address only seasoned programmers.

The way kids should learn how to program is exactly like that, though. You can create a floor with square tiles and stand in one. Then let the kids give you orders to guide you where they want you to go.

But Google should have never produced such a difficult puzzle meant for kids programming. This puzzle should have been addressed to adults.

Anyway, here are the questions:

Question 1: Question 2: Question 3: Question 4: Question 5: Question 6: And here are the answers:      Note:

By the way, the answer for question 5 can also be used to solve question 4.

Obviously, the goal is for the bunny to eat all the carrots.

The puzzle does not make it clear what considers as optimal solutions. From the image below, we can understand that optimal solutions are those which use the least amount of components. The number in each question denotes the minimum mumber of components needed to solve it. Of course, since question number 4 can also be solved using the solution from question 5, one could argue that question 4 should have the number 6 (instead of 7) for denoting the components needed. But using the solution from question 5 to solve question 4 is far fetched, so I believe that denoting 7 as the compenent number for question 4 is better as it stands.

It is interesting to see what the optimal solution for question 6 is, if we consider as optimal solutions not those with the least number of components but those with the least number of bunny steps.
Then the answer to question 6 could be the following:
– – ) [ – ) – ( – ) – ]
where – means move one step, ) means turn clockwise, ( means turn counter-clockwise, and [ ] means repeat 4 times what is inside the square brackets. I depict this answer below, using two images, since it does not fit in one.  Final note:

Of course, the algorithms that the puzzle expects as optimal are unacceptable to me. If I would see someone creating these algorithms, I would tell them that they are far from safe.

You should be able to look at an algorithm and immediatelly deduce its validity, correctness, function, purpose, etc. You should be able to look at an algorithm and immediately understand what its results will be.

Programming is not about which programmer is more clever than the other. It is not an exercise in obfuscation. It is, or it should be, an exercise in clarity. 