blockly

How to simplify this Blockly program drawing a snowflake?


The question says that:

The program shown below on the left draws a snowflake. It uses 33 code blocks. Can you re-write it so that it uses at least one function and less than 30 blocks.

How can I draw this using Blockly?


Solution

  • After some research I don't think recursive function is the solution in this case but in python I would try something like this

    def drawLeaf(direction):
        // Draw your leaf in this direction using your blocks code
    
    for direction in [0, 72, 144, 216, 288]:
        drawLeaf(direction)