3
Given the width and height of a line in characters, draw it using ascii characters.
Input
Two integers separated by a space, the first one being the width, the second one being the height.
Example: 5 3
Output
An oblique line formed with the characters /\|_
, that has the width and height given in the input. The characters must be as well distributed as possible (eg as close as possible from a perfect line), any "leftover" characters being placed near the end of the line.
Good output for 5 3
:
\_
\_
\
Bad output for 5 3
:
\__
\
\
Test cases
1 1
:
\
3 4
:
\
|
\
\
10 3
:
\__
\__
\___
4 7
:
\
|
\
|
\
|
\
-3 3
:
/
/
/
3 8
:
\
|
|
\
|
|
\
|
-3 -8
:
|
\
|
|
\
|
|
\
6 2
:
_
\_
\__
0 2
:
|
|
2 0
:
__
Clarification
The characters _
and |
represent lines between "pixels". As it is obvious for _
to reprensent the line below the place we put it, it is not that obvious for |
(placed in the center). Therefore, it must be arbitrarly decided that the line is located on the right. This next example thus shows a perfect square:
__
| |
| |
__
That being, a line that begins with a |
is actually 1 character wider, with the first column looking empty and a line beginning with a _
is actualy 1 character higher, with the first row looking empty.
Rules
- As usual, this is code-golf, shortest answer in bytes wins.
- Standard loopholes are forbidden.
1What do you mean by "well distributed"? – Zgarb – 2016-10-27T09:25:58.937
It's hard to explain, that's why I put a good and a bad example in "output". (I added "as close as possible from a perfect line") – SteeveDroz – 2016-10-27T10:11:49.607
@SteeveDroz did you see the edits I've made to your monthconcatenation? – Jonathan Allan – 2016-10-27T10:42:18.437
1
Perhaps you mean something like this older challenge, which had the restriction
– Zgarb – 2016-10-27T11:06:18.3630 <= y <= x
. There it was required that the output is identical to Bresenham's algorithm. There are some general rules for being a well distributed line, but they are indeed hard to explain.Ugh! I thought I was being clever and I missed this one :-( Oh well, my question is a duplicate. – SteeveDroz – 2016-10-27T11:28:26.533