Write a program or function that draws a tree of trees, thus constructing a forest.
The trees are drawn like stacking a pyramid. The first (top) row contains 1
tree, the next row down contains 2
(for a total of 3
), the next contains 3
(for a total of 6
), and so on. If there aren't enough trees to complete a full row, fill it to the left and leave the spots on the right empty. Additionally, lower-level trees slightly overlap upper-level trees due to their placement.
This is a forest of size 1
/\
//\\
///\\\
||
||
This is a forest of size 2
/\
//\\
/\///\\\
//\\ ||
///\\\||
||
||
This is a forest of size 3
/\
//\\
/\///\\\/\
//\\ || //\\
///\\\||///\\\
|| ||
|| ||
This is a forest of size 4
/\
//\\
/\///\\\/\
//\\ || //\\
/\///\\\||///\\\
//\\ || ||
///\\\|| ||
||
||
This is a forest of size 5
(note the top of the fifth tree is covering the trunk of the first tree)
/\
//\\
/\///\\\/\
//\\ || //\\
/\///\\\/\///\\\
//\\ || //\\ ||
///\\\||///\\\||
|| ||
|| ||
(skip a few)
This is a forest of size 8
(extending the pattern)
/\
//\\
/\///\\\/\
//\\ || //\\
/\///\\\/\///\\\/\
//\\ || //\\ || //\\
/\///\\\/\///\\\||///\\\
//\\ || //\\ || ||
///\\\||///\\\|| ||
|| ||
|| ||
and so on.
Input
A single positive integer in any convenient format, n > 0
.
Output
An ASCII-art representation of the forest, following the above rules. Leading/trailing newlines or other whitespace are optional, provided that the trees all line up appropriately.
Rules
- Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
n
, what are the positions of the trees? \$\endgroup\$