Блог пользователя royappa

Автор royappa, история, 4 года назад, По-английски

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

  • Проголосовать: нравится
  • +27
  • Проголосовать: не нравится

»
4 года назад, # |
Rev. 2   Проголосовать: нравится -53 Проголосовать: не нравится

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 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I found this 4 block solution to the last one:

Spoiler
  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 года назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

6 blocks solution for 4th problem

Spoiler
  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

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

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

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