20
2
Create a function which given a number of lines n
, makes a bigA
.
- The horizontal bar of
bigA
must be at the middle row, or the lower of the two ifn
is even - Assume a monospace font for output
Output should be a string (or similar, eg character array) with clear linebreaks to break up the lines, and with correct whitespace for left-padding (you can assume \t to be 4 spaces). There can be any whitespace on the right.
Examples
n = 1
A
n = 2
A
AAA
n = 3
A
AAA
A A
n = 4
A
A A
AAAAA
A A
n = 5
A
A A
AAAAA
A A
A A
This is inspired by Create an "H" from smaller "H"s
May I add whitespace to the right side? Also, is trailing newline allowed? – Bubbler – 7 years ago
@Bubbler, Any whitespace on the right side is fine, no trailing newline though – Budd – 7 years ago
Are we allowed to return 2D character arrays instead of strings? (hint: it's usually recommended to allow any kind of output) – Olivier Grégoire – 7 years ago
1@OlivierGrégoire Sure, as long as there is a clear break for the lines (eg an "\n" element, nested arrays) – Budd – 7 years ago
Is an array of strings representing lines ok? Also, can I print directly to stdout? – Asone Tuhid – 7 years ago
Yes, output is flexible as long as spacing and newlines are clearly represented somehow – Budd – 7 years ago
Can we use another content character than "A" ? in particular, is lowercase "a" allowed ? – Ton Hospel – 7 years ago
1@TonHospel, No, that really defeats the purporse of this – Budd – 7 years ago
Can
____A\bA____
be used instead of____A____
?\b
stands for ASCII backspace character. – Radek – 7 years ago