Your task is to write a program or a function that prints an ASCII triangle. They look like this:
|\
| \
| \
----
Your program will take a single numeric input n
, with the constraints 0 <= n <= 1000
. The above triangle had a value of n=3
.
The ASCII triangle will have n
backslashes (\
) and vertical bars (|
), n+1
lines and dashes (-
), and each line will have an amount of spaces equal to the line number (0-based, ie first line is line 0) besides the ultimate line.
Examples:
Input:
4
Output:
|\
| \
| \
| \
-----
Input:
0
Output:
In this test case, the output must be empty. No whitespace.
Input:
1
Output:
|\
--
Input & output must be exactly how I specified.
This is code-golf, so aim for the shortest code possible!
0
can have any unexpected output since it is an edge case (especially since you requested that the number of dashes must be one more than the input number) \$\endgroup\$ – Kritixi Lithos Feb 8 '17 at 15:10