在体育比赛中,经常会出现获奖者出现在领奖台上的情况,第一名的人排在中间最高,第二名的人排在中间高度的左侧,第三名的人排在最低和在右边。我们将在此处进行一些特殊的调整来重新创建它。
领奖台如下:
@---@
| @ |
@---@| | |
| @ || | |
| | || | |@---@
| | || | || @ |
这将构成这一挑战的基础。下一步是使讲台足够宽,以适合讲台上的人员(可打印ASCII字符串)。但是,我们要确保美观(因为这是一次绝佳的拍照机会),因此每个讲台的宽度必须相同,并且宽度必须为奇数。此外,人们(显然)会希望站在讲台的中央,因此,弦线必须尽可能地居中。(您可以向左或向右对齐,并且不需要保持一致。)上面的讲台是最小的尺寸,被认为是3
宽的。
例如,假设输入分别["Tom", "Ann", "Sue"]
代表第一,第二和第三名,则输出以下讲台:
Tom
@---@
Ann | @ |
@---@| | |
| @ || | | Sue
| | || | |@---@
| | || | || @ |
然而,如果我们Anne
不是Ann
,我们需要去到下一个大小,5
和中央琴弦尽可能最佳。在这里,我正在对齐,因此“额外”字母Anne
位于中心的左侧,但是您可以选择要对齐到哪一侧。
Tom
@-----@
Anne | @ |
@-----@| | |
| @ || | | Sue
| | || | |@-----@
| | || | || @ |
让我们来命名一些更长的名称。怎么样["William", "Brad", "Eugene"]
:
William
@-------@
Brad | @ |
@-------@| | |
| @ || | | Eugene
| | || | |@-------@
| | || | || @ |
在这里,我们可以看到Brad
有很多空格,Eugene
少了一些,并且William
恰到好处。
对于更长的测试用例,如何["A", "BC", "DEFGHIJKLMNOPQRSTUVWXYZ"]
:
A
@-----------------------@
BC | @ |
@-----------------------@| | |
| @ || | | DEFGHIJKLMNOPQRSTUVWXYZ
| | || | |@-----------------------@
| | || | || @ |
最后,我们有尽可能小的输入,例如["A", "B", "C"]
:
A
@---@
B | @ |
@---@| | |
| @ || | | C
| | || | |@---@
| | || | || @ |