The Task
In this challenge, your task is to draw an ASCII art representation of several stacks of boxes of increasing height.
You are given as input the number of stacks, which is a positive integer.
The first stack contains one box of size 2x2
.
The second stack contains 2 boxes of size 3x3
.
In general, the k
th stack contains k
boxes of size (k+1)x(k+1)
.
The borders of each box are drawn using the characters -|+
, and their interior consists of whitespace.
Adjacent boxes share their borders, and corners should always be drawn with +
, even when they are part of a border of another box.
Examples
Output for 1
:
++
++
Output for 2
:
+-+
| |
+-+
++ |
++-+
Output for 3
:
+--+
| |
| |
+--+
| |
+-+ |
| +--+
+-+ |
++ | |
++-+--+
Output for 5
:
+----+
| |
| |
| |
| |
+----+
| |
| |
| |
+---+ |
| +----+
| | |
| | |
+---+ |
| | |
| +----+
+--+ | |
| +---+ |
| | | |
+--+ | |
| | +----+
+-+ +---+ |
| +--+ | |
+-+ | | |
++ | | | |
++-+--+---+----+
Rules and Scoring
The input can be received from STDIN, as a command line argument, or as a function argument. Output must go to STDOUT or closest equivalent. Any finite amount of trailing whitespace is allowed, as are preceding and trailing newlines, but there cannot be any extra preceding spaces.
This is code-golf, so the lowest byte count wins. Standard loopholes are disallowed.
n
andn-1
are relatively prime. Two pluses will never overlap. \$\endgroup\$Integer.MaxValue
as input. \$\endgroup\$Integer.MaxValue
or equivalent. \$\endgroup\$