Eiffel Towers: Create a large "A" from "A"s
05AB1E, 13 bytes
Uses the 05AB1E encoding. Try it online!
Ð # Triplicate the input. ;î # Compute ceiling(n / 2). ¹ # Push the first input again. ) # Wrap into an array. For input 7, this would result in: [7, 7, 4, 7]. 'A # Push the character 'A' 1376S # Push the array [1, 3, 7, 6]. These are the directions of the canvas. This essentially translates to [↗, ↘, ↖, ←]. Λ # Write to canvas using the previous three parameters.
I should probably document the canvas a little bit more (and a lot of other functions), but this basically sums it up. The canvas has different 'modes' based on the parameter types given. The canvas command has three parameters: <length> <string> <direction>.
Since the length and direction parameters are lists, it 'zips' these lists to create a set of instructions to be executed. The string parameter is just the letter A, so this is the fill character used by all instructions. The canvas interprets this as the following set of instructions (for input 7):
- Draw a line of length 7 with the string A in direction ↗
- Draw a line of length 7 with the string A in direction ↘
- Draw a line of length 4 with the string A in direction ↖
- Draw a line of length 7 with the string A in direction ←
The directions are translated in the following manner:
7 0 1 ↖ ↑ ↗ 6 ← X → 2 ↙ ↓ ↘ 5 4 3
If nothing has been outputted, 05AB1E automatically outputs the canvas result.
17 15 bytes
Try it online! Link is to verbose version of code. Explanation:
Print the horizontal bar of the big
A. (For even numbers, the
n+1th overlaps the right side anyway.)
Move to the top of the big
Print both sides of the big
Python 2, 80 bytes
lambda n:'\n'.join(' '*(n+~i)+('A'+' A'[i==n/2]*n*2)[:i*2]+'A'for i in range(n))
Try it online!
Divide the desired output into the left whitespace, left
A plus middle whitespace or
As, and the right
A. Compute the middle part using slicing on a fixed string. This allows to use the same way to generate the first line.