Gabonese Flag explainer


#1

The aim of this puzzle: Create the Gabonese flag.
Walkthrough of the solution: The Gabonese flag has three horizontal stripes; the top stripe is green, the middle stripe is yellow and the bottom stripe is blue. To re-create the flag there needs to be 9 boxes — 3 boxes tall and 3 boxes wide. drawBox(green) will draw one green box (updating the color will change the color of the box). newLine() is used to make boxes appear below other boxes.
Sample code solution:
(Tap below to reveal)

drawBox(green);
drawBox(green);
drawBox(green);
newLine();
drawBox(yellow);
drawBox(yellow);
drawBox(yellow);
newLine()
drawBox(blue);
drawBox(blue);
drawBox(blue);

JavaScript Concepts: Calling Functions, Identifiers
Grasshopper Concepts: drawBox(), newLine()


#2

I do not under stand


#3

Whenever you press the green play button, all of the code inside of the “Your Code” section gets run, line by line from top to bottom. You need to create a list of commands that create a specific pattern when you read it from the first line to the last. In this puzzle, that pattern is the Gabonese Flag with has three horizontal stripes (green, yellow, and blue). You can see in the “Example Solution” section of the app that each stripe is three boxes wide.

To create a green stripe, you would need to draw three green boxes in a row which can be done by writing:

drawBox(green);
drawBox(green);
drawBox(green);

To move the grasshopper down to the next row for your next stripe, you use newLine(). Then you can use the same pattern to create a different colored stripe, like yellow.

After you have a green and yellow stripe, you can move the grasshopper to a newLine() again and create the last row of three blue boxes.

Hope this is helpful. If there are any parts that are unclear, feel free to ask me about them!

–Frankie


#6

So the drawbox meathead draws a box. To tell the script (drawbox) you say the color that the code wants you to do.