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: