The aim of this puzzle: Recreate the nursery rhyme, “One, Two, Buckle my Shoe”.
Walkthrough of the solution: There’s quite a few lines of code here, but if you run it, you’ll see that it’s pretty close to what you need. It’s just messing up the last two numbers which should be 3 and 4. Let’s ignore the two
print() statements that have the words of the nursery rhyme. You see that the
counter variable starts with the value 1, and then it gets printed. Then it gets assigned a new value using
counter = ..., and the new value is
counter + 1. That means, you take whatever value is stored inside
counter, and add
1, and then store that value back inside of
counter. The end result is just adding 1 to the
counter value. Since you always want to be counting up by 1 in this puzzle, wherever you see
counter = counter + ... it should be
counter = counter + 1.
Sample code solution:
(Tap below to reveal)
var counter = 1; print(counter); counter = counter + 1; print(counter); print('Buckle my shoe!'); counter = counter + 1; print(counter); counter = counter + 1; print(counter); print('Knock at the door!');
Grasshopper Concepts: print()