22
1
Challenge
Given an ASCII operator from the list below and a number n, draw an ASCII representation of the operator using that operator as the character with the line segments of the operator having length n.
Input
An ASCII character from the list = + - x /
and an integer n
where n >= 1
. (I'm using x
instead of *
and /
instead of ÷
, but you could use either one, whichever is easier). For +
and x
, you only have to handle odd numbers to avoid issues with alignment.
Output
An ASCII drawing of the operator composed of the character with segments of length n. Horizontal portions should have spaces between the characters to offset vertical/horizontal distance differences.
Rules
This is code-golf, so shortest code in bytes wins. Standard loopholes are forbidden.
Examples
Input: + 3
+
+ + +
+
Input: = 4
= = = =
= = = =
Input: = 10
= = = = = = = = = =
= = = = = = = = = =
Input: - 2
- -
Input: / 10
/
/
/
/
/
/
/
/
/
/
Input: x 7
x x
x x
x x
x
x x
x x
x x
can you add the test case for
= 10
? – Rod – 2016-11-07T16:40:32.4971I assume "x" and "+" imply odd numbers? (I just saw DrMcMoylex asked nearly the same question.) – Martin Rosenau – 2016-11-07T16:48:54.857
1@MartinRosenau Yes, from the Input section: "For + and x, you only have to handle odd numbers to avoid issues with alignment." – corvus_192 – 2016-11-07T17:01:50.707
Why are X and / not spaced out? – Adám – 2016-11-08T11:37:36.640
1is leading whitespace allowed? – Adám – 2016-11-08T12:15:44.487
@Adám As long as the output looks correct. – Yodle – 2016-11-08T14:21:06.100
@Adám Oh and to answer your first question, because they technically don't have horizontal bits that are right next to each other like =, -, and +. I considered specifying that they be spaced similarly, but decided against it. – Yodle – 2016-11-08T14:52:13.827
To clarify: if we use
÷
for the division input, the output can be a diagonal line of÷
? – DLosc – 2016-11-09T22:33:48.573@DLosc Hmm, I had not considered what the output would be for ÷. I guess you could do what you said, since the circles in ÷ would be kinda difficult to express. – Yodle – 2016-11-09T22:50:25.873