28
4
Given an input of two integers n and m, output an ASCII ladder of length n and size m.
This is an ASCII ladder of length 3 and size 3:
o---o
| |
| |
| |
+---+
| |
| |
| |
+---+
| |
| |
| |
o---o
This is an ASCII ladder of length 5 and size 1:
o-o
| |
+-+
| |
+-+
| |
+-+
| |
+-+
| |
o-o
This is an ASCII ladder of length 2 and size 5:
o-----o
| |
| |
| |
| |
| |
+-----+
| |
| |
| |
| |
| |
o-----o
To be specific:
The length (n) represents how many squares the ladder is made up of.
The size (m) represents the width and height of the interior of—that is, not counting the "borders"—each square.
Each square is made up of the interior area filled with spaces, surrounded by
-
s on the top and bottom,|
s on the left and right, and+
s at all four corners.Borders between squares merge together, so two lines in a row with
+--...--+
merge into one.The corners of the entire ladder are replaced with the character
o
.You may optionally output a trailing newline.
The length of the ladder (n) will always be ≥ 2, and the size (m) will always be ≥ 1.
Input can be taken as a whitespace-/comma-separated string, an array/list/etc., or two function/command line/etc. arguments. The arguments can be taken in whichever order is most convenient / golfiest.
Since this is code-golf, the shortest code in bytes wins.
Tip: The examples above can also be used as test cases.
Do we have to take length first, then size? – RK. – 2016-01-10T00:50:02.717
@RK. You can take them in whichever order is more convenient. – Doorknob – 2016-01-10T16:55:13.567
1Can there be a leading newline? – Conor O'Brien – 2016-01-10T22:35:38.473
1@CᴏɴᴏʀO'Bʀɪᴇɴ Uhh... I'm going to go with no on that one. – Doorknob – 2016-01-10T23:01:03.377
1Okay :P It was worth a shot. – Conor O'Brien – 2016-01-10T23:01:46.457
Hey, issacg's Pyth answer is shorter! Not mine! – Akangka – 2016-01-16T22:14:08.880
@ChristianIrwan ... oh, whoops, I can't count. Fixed. – Doorknob – 2016-01-16T22:34:37.370