Dragon curve

In 13 lines. The actual logic is 3 lines.

Log in to post a comment.

Canvas.setpenopacity(0.8);

const turtle = new Turtle();
turtle.penup();
turtle.left(90);
turtle.goto(-50,20);
turtle.pendown();

function walk(i) {
    turtle.forward(0.5);
    turtle.left(((i&-i)<<1)&i?90:-90);
    return i < 2**16+1;
}