Gabonese Flag explainer

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()

7 Likes

I do not under stand

5 Likes

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

5 Likes

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

7 Likes

How does the drawBox() function know to draw horizontal long box as with Gabonese flag or a small box as with French Flag

3 Likes

Hey there,

All of the boxes are the same size. By calling the function 3 times with the same color, the 3 boxes look like a stripe.

–Ben

5 Likes

are you from welch Newnan GA

1 Like

I don’t understand neither so they put a hint button so tap it and I thinks so they will so never give up cater:wink::wink::wink::wink::wink::heart::heart:

no sorry l’am from africa

chrome 78 beta - numerous errors prevent proper function for buttons. unable to complete lesson due to errors… plz fix in meantime i have to use older browser versions or FFox.

Hey there, those warnings are unrelated. They are warning that a future version of Chrome is going to make some slight changes to how cookies work on websites.

Can you describe the issue you are having?

Thanks,
Ben

– resolved – was my mistake

Duh with cheese and stuff, me too

Hi, beginning to understand at the very early stages of coding could you enlighten me on some other aspects that may be needed to start to be able to build my own and thank you so much you’re very self-explanatory and it’s clear and concise appreciate that Dixie Nunley/ Longoria