26
5
In sporting competitions, it often happens that winners are presented on podiums, with the first-place person on the highest in the middle, the second-place person on the middle height to the left, and the third-place person on the lowest and to the right. We're going to recreate that here with some special tweaks.
The podiums are presented below:
@---@
| @ |
@---@| | |
| @ || | |
| | || | |@---@
| | || | || @ |
This will form the basis for this challenge. The next step is to make the podiums wide enough to fit the people (printable ASCII strings) that are on them. However, we want to ensure aesthetic beauty (because this is a fantastic photo opportunity), so each podium needs to be the same width, and the width must be odd. Additionally, the people will (obviously) want to stand in the center of the podium, so the strings must be centered as best as possible. (You can align to either the left or the right, and it doesn't need to be consistent.) The above podiums are the minimum size, and are considered 3
wide.
For example, given the input ["Tom", "Ann", "Sue"]
representing first-, second-, and third-place respectively, output the following podiums:
Tom
@---@
Ann | @ |
@---@| | |
| @ || | | Sue
| | || | |@---@
| | || | || @ |
However, if we have Anne
instead of Ann
, we'll need to go up to the next size, 5
, and center the strings as best as possible. Here, I'm aligning so the "extra" letter of Anne
is to the left of center, but you can choose which side to align to.
Tom
@-----@
Anne | @ |
@-----@| | |
| @ || | | Sue
| | || | |@-----@
| | || | || @ |
Let's go for some longer names. How about ["William", "Brad", "Eugene"]
:
William
@-------@
Brad | @ |
@-------@| | |
| @ || | | Eugene
| | || | |@-------@
| | || | || @ |
Here we can see that Brad
has a lot of whitespace, Eugene
less so, and William
fits just right.
For a longer test case, how about ["A", "BC", "DEFGHIJKLMNOPQRSTUVWXYZ"]
:
A
@-----------------------@
BC | @ |
@-----------------------@| | |
| @ || | | DEFGHIJKLMNOPQRSTUVWXYZ
| | || | |@-----------------------@
| | || | || @ |
Finally, we have the smallest possible input, something like ["A", "B", "C"]
:
A
@---@
B | @ |
@---@| | |
| @ || | | C
| | || | |@---@
| | || | || @ |
- Input and output can be given by any convenient method.
- The input is guaranteed non-empty (i.e., you'll never receive
""
as a name). - You can print it to STDOUT or return it as a function result.
- Either a full program or a function are acceptable.
- Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately.
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
Do all even-length names have to be aligned in the same direction? – Sparr – 2019-02-21T00:42:10.437
1Why do the podiums in the last example output have length 3 instead of length 1? – bruderjakob17 – 2019-02-21T13:33:45.547
3@bruderjakob he states at the beginning "the podiums above are the minimum size and are considered 3 wide" – rtpax – 2019-02-21T13:36:46.047