Armenian Flag Shortcuts explainer

The aim of this puzzle: Create the Armenian flag with one line of code.

Walkthrough of the solution: When there is a space in the string given to drawBoxes(), it will create a newLine().

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 Armenian flag, you need 9 boxes: red, red, red, new line, blue, blue, blue, new line, then orange, orange, orange. That means the string that goes inside of drawBoxes() is 'rrr bbb ooo'.
Sample code solution:
(Tap below to reveal)

drawBoxes('rrr bbb ooo');

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

3 Likes