Gabonese Flag Shortcuts explainer

The aim of this puzzle: Create the Gabonese flag with one line of code.
Walkthrough of the solution: This puzzle is very similar to the Gabonese Flag Helper. There is just one extra shortcut – newLine() can be replaced with a space in the string given to drawBoxes().

Inside of the parentheses of drawBoxes() you need to edit the string. drawBoxes() will look at each character in its string: if it’s a letter, draw a box with the color that letter stands for; if it’s a space, go to a new line. So, drawBoxes('g g') is the same as drawBox(green); newLine(); drawBox(green);

To draw the Gabonese flag, you need three rows: green, green, green, new line, yellow, yellow, yellow, new line, then blue, blue, blue. That means the string that goes inside of drawBoxes() is 'ggg yyy bbb'.
Sample code solution:
(Tap below to reveal)

drawBoxes('ggg yyy bbb');

JavaScript Concepts: Calling Functions, Identifiers
Grasshopper Concepts: drawBoxes()

11 Likes

Initially missed your y and added 3 more in my solution before my BBB. It told me that I made an error and I went back to correct it. My corrected solution ran correctly but it has me locked in and keeps telling me to hit reset. Don’t see a"reset". How do I proceed? Thanks

5 Likes

Found reset button, did my corrected solution again and it ran correctly but still will not complete the lesson. Tells me, again, that a new line of code was added and to hit reset again.

2 Likes

In this puzzle, the entire flag can be created using 1 line of code. It’s possible to make a flag using more lines of code, but this puzzle will only pass if you can do it in 1 line.

There are 11 commands that need to run in total: 3 greens, a new line, 3 yellows, a new line, 3 blues. This is represented as a string, 'ggg yyy bbb'. You could break up this string and put each part into a separate drawBoxes() call, but there’s no need.

–Frankie

On desktop on either browsers mozilla or chrome …even for 1hit of space bar , the space counted is more and error is shown as in the screenshot attached …looks its set up mobile app space bar.

Thanks .
Update if any

1 Like

Hey there,

That feedback message is looking at the 1st drawBox() function call you have. It notices that it is incomplete, and is telling you how to complete it.

You can just delete the 1st drawBox() function call, as you’ve added a 2nd with the correct code.

Hope this helps!
Ben

3 Likes

Was stuck in this stage despite entering the correct code. Your suggestion paved the way, thank you.

2 Likes

it keeps telling me I have an error, even if I enter the code correctly.

There is a bug in this site, that’s what people are entering but the response is different

nice i am completed this event is very nice i am really entertainment this event

nice it is very helpful


how to solve problem

1 Like

Hey there,

Make sure you just have one drawBoxes() function call, with the string 'ggg yyy bbb' inside the parentheses.

Hope this helps!
Ben

There is still a bug. I am entering ( ‘ggg yyy bbb’) and it gives the same error as stated by other users.

1 Like

Hey there, make sure you just have one drawBoxes() function call, with that string inside it.
–Ben

no there isn’t, I thought there was too. you have to delete by pressing the back button then editing what was previously there before you started typing “ggg yyy bbb” in the very top first one .

Finished the code correctly, can’t move on.

1 Like

Hey there, take a look at the other posts in this thread. If you still need help, post a screenshot of your code and I’ll take a look.

Ben

Still does not work; snip attached.

Thanks for the feedback