A Google Doodle About Programming! (+ Solutions)

in #programming7 years ago

Thumbnail Image
So recently I found doodle created on 2017 december 4, about programming. Well it's kids coding, but I thought it could be fun so I gave it a go. It's really simple, you have:

  • A Rabbit, this is your character you can move around
  • Carrots, you need to collect these with the rabbit
  • A map, the rabbit has a map, where it can move, you can't fall off the map

You have basic blocks, which represents the code:

  • Move, this moves forward by 1 step
  • Turns, you can turn left or right
  • Loops, you can repeate any of the code blocks, by the specified loop count

You can try it for yourself and see how many did you get.
But the challange is to complete the map with the limit specified on how many blocks to use. For example if the limit is 2:
You can only use 2 blocks. Looping 3 or 4 times doesn't count as 3 or 4 times the blocks, so if you loop the forward movement 4 times, that's still 2 blocks.
We have 6 maps, each with a different limit of blocks to use.
Spoiler Alert if you want to try and solve it yourself, stop reading here and do the challanges.

Level 1.

This is the tutorial level, so it's really simple, you just have to insert two forward blocks, and you're good to go:
Level 1 completion

Level 2.

This is a tutorial level too, here they introduce the turn block. All you have to do is:
step forward twice, turn and step froward twice again
Level 2 compeltion

Level 3.

This is still a tutorial level, where they introduce loops, one of the biggest twists in this game. The hard parts start when you need to create looping algorithms to solve the problem. But this is really easy too!
Just move forward twice, turn, and loop this whole thing 4 times.
Level 3 completion

Level 4.

This is where the hard part starts, you have no more tutorial levels! This is basically the same level as the previous one, you just need to do the looping twice and somehow invert the movement after the first 4.
So start by implementing the same algorithm as before:
two forward, turn right and loop the whole thing 4 times.
Now we have to implement the reversing. To do this turn 2 times left to cancel the last right turn, and invert the direction.
Then we loop the whole thing twice to complete the map:
Level 4 completion

Level 5.

This level was never seen before, but we can divide the map to 4 identical parts. So the logic is the same. We have a main part that completes one of the 4 parts. We modify the direction at the end of that block, and we repeat this whole thing 4 times to complete all 4 parts:
Level 5 completion

Level 6.

Now this is the last and the hardest level in the game, we still have 4 identical parts, but they're not connected so we need to find a new algorithm for this. I found an algorithm that can complete the level with less blocks than said in the level map. But don't belive me, try it out yourself. Basically i move in circles and the circles keep getting bigger. I also use the You can't fall off the map feature of the game, to keep the circles from getting too big. Check this out:
Level 6 completion
I'm only using 4 blocks instead of the 6 specified in the level selection:
Block Limit

Summary

It was a fun game and challange to complete. I'm especially happy because I managed to complete the last level below the specified limit! Maybe there are other solutions to the other levels too, so be sure to share your own solutions in the comment section below.
Thank you for reading this post!

Sort:  

Congratulations @ah101! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Coin Marketplace

STEEM 0.16
TRX 0.15
JST 0.028
BTC 54391.40
ETH 2283.95
USDT 1.00
SBD 2.29