royappa's blog

By royappa, history, 4 years ago, In English

OK so I came across an old Google Doodle recently:

https://www.google.com/doodles/celebrating-50-years-of-kids-coding

It is to write six programs in that applet using a block language (like MIT Scratch). Very cute.

Now, Google gives you a ribbon if you write the shortest code (in terms of blocks). The steps in their shortest code program is shown in the screenshot below, it's the number inside the ribbon. To be very clear, this is like shortest lines-of-code, not fewest runtime steps. A short program may not be efficient.

Now for the challenge: I was able to solve that last program with 5 blocks instead of Google's shortest solution of 6. So, see if you also can do better than Google's shortest solution, on any of the programs. I could only improve the last one.

And don't forget to share this with your young friends who might be interested in coding!

image

  • Vote: I like it
  • +27
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
Rev. 2   Vote: I like it -53 Vote: I do not like it

Blocks programming languages are friendly programming languages for kids. I personally hate blocks programming languages as you are not as free as typing codes. Literally, not a lot of people on codeforces would care about that challenge.

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I found this 4 block solution to the last one:

Spoiler
  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I did not realise one could change the loop count... (its possible to solve all in googles optimal number of steps without changing the loop count...)

»
4 years ago, # |
  Vote: I like it +11 Vote: I do not like it

6 blocks solution for 4th problem

Spoiler
  • »
    »
    4 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    Fantastic — boy, Google really didn't spend any effort on figuring out the true "shortest", huh?!!

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I think the level 4th level only need 6 blocks:

loops(2) {
   loops(8) {
      move()
      move()
      turn("left");
   }
   turn("right");
}