Given a positive integer N
, output this doubling pattern of slash squares/rectangles.
For N=1
, the base is:
/\
\/
The next square is added in the bottom right direction for N=2
:
/\
\/\
\/
After that, a 2x1 rectangle is added in the bottom left direction for N=3
:
/\
/\/\
\ \/
\/
Then a 2x2 square is added in the top left direction for N=4
:
/\
/ \
\ /\
\/\/\
\ \/
\/
A 2x4 rectangle is added in the top right:
/\
/ \
/\ \
/ \ \
\ /\ /
\/\/\/
\ \/
\/
And so on. The direction in which squares and rectangles are added cycles counterclockwise, and the shape which is added alternates between squares and rectangles.
You may output as an array of lines / matrix of characters, and input may be 0-indexed or 1-indexed. Trailing whitespace in the output is allowed.
Testcases:
1:
/\
\/
2:
/\
\/\
\/
4:
/\
/ \
\ /\
\/\/\
\ \/
\/
7:
/\
/ \
/\ \
/ \ \
/\ /\ /\
/ \/\/\/ \
/ \ \/ \
/ \/ \
\ \ /
\ \ /
\ \ /
\ \/
\ /
\ /
\ /
\/
10:
/\
/ \
/ \
/ \
/ \
/ \
/ \
/ \
/\ \
/ \ \
/ \ \
/ \ \
/ \ \
/ \ \
/ \ \
/ \ \
\ /\ /\
\ / \ / \
\ /\ \ / \
\ / \ \ / \
\ /\ /\ /\ / \
\ / \/\/\/ \ / \
\ / \ \/ \ / \
\/ \/ \/ \
\ \ / \
\ \ / \
\ \ / \
\ \/ \
\ / \
\ / \
\ / \
\/ \
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\/