26
4
Today's Google doodle is about Celebrating 50 years of Kids Coding: The goal is program the path of a little bunny so that it can eat all the carrots. There are 4 types of blocks (see pictures below):
From left to right:
O("...", k)
= orange piece: these arefor
loops which executes k times the program"..."
.G
= green piece: go one step forward if you can, otherwise do nothingBl
= blue piece: turn right and stay on the same blockBr
= blue piece: turn left and stay on the same block
The code above can be written as
O(O(G G Br, 4) Bl Bl, 23)
Each block (G, Bl, Br, O(...,k)
) counts as 1 unit, so this program is of length 7. Note than the value of k
is included inside the 1 unit of O
.
There are 6 levels. To finish a level you need to eat all the carrots. It is not a problem if your program is not fully executed, the level finishes directly when you eat the last carrot.
We assume that all the 4 types of blocks are available in every level.
Your task is to find a single program which solves every level of the game.
Shortest program in blocks wins.
Screen shots of each level:
Level 1:
Level 2:
Level 3:
Level 4:
Level 5:
Level 6:
Good find! I did try this approach but didn't happen on this particular combination before giving up and going for my 9 block solution. – Sparr – 2017-12-10T02:04:18.783
2
The user Alex claims to have found a shorter solution.
– Jonathan Frech – 2019-05-03T20:06:24.103@JonathanFrech indeed he has! That 10-rep limit is annoying. I get that we have to prevent spam, but shouldn't new users have at least a moderated way of posting answers? Freedom of speech and stuff. – Reinis Mazeiks – 2019-05-04T10:38:06.390
@R.M I was also a bit irritated upon seeing the problem. I guess SE simply is not designed for one-off answers, as frustrating this probably is for Alex ... – Jonathan Frech – 2019-05-04T13:07:59.263
1Why did you edit this into your own old answer instead of posting it as a new answer? – Sparr – 2019-05-05T18:54:53.070