您不想为昂贵的体系结构程序花钱,因此决定自己动手做。您决定使用ASCII设计建筑物。您的程序将采用以特定方式设置格式的单个字符串,并且程序将输出建筑物。
输入值
输入由单行字符组成。可以假定它仅包含字母a-j
,数字1-9
,符号-
和+
。
输出说明
对于每个字母a-j
,程序将输出一条垂直线,如下所示。我们将其称为一列。
.
..
...
****
*****
******
-------
--------
+++++++++
++++++++++
abcdefghij
例如,输入abcdefgfedefghgfedc
将输出:
.
* ***
*** *****
***** *******
---------------
-----------------
++++++++++++++++++
+++++++++++++++++++
字母可以以正整数为前缀n
,这将n
在列下方添加空格字符。我们将其称为偏移量。例如,使用S
注解空格,输入3b2b3b
将输出:
+ +
+++
S+S
SSS
SSS
字母也可以加上负整数作为前缀-m
,这将删除列的底部m
非空白字符(不将其替换为空白,而是将其完全删除)。我们称其为片。例如,输入-1j-2j-3j-4j-5j-6j-7j-8j
将输出:
.
..
...
*...
**...
***...
-***...
--***...
+--***..
可以将偏移量和切片应用于同一行,但是偏移量必须先行。换句话说,字母可以以开头n-m
,其中n
偏移量m
的大小是切片的大小。例如,使用S
注解空格,输入“ 2-4j”将输出:
.
.
.
*
*
*
S
S
最后,+
在两列之间使用的运算符表示应将它们堆叠在同一列中,而不是在单独的列中。例如,输入2-4ja输出:
.
.
.
*
*
*
S
S+
而输入2-4j+a
输出:
+
.
.
.
*
*
*
S
S
这是一个示例输入:
abiehef+ehfhabc
以及结果输出:
*
-
. -
. . +. .
* * +* *
* * ****
********
--------
-------- -
+++++++++ ++
+++++++++++++
看起来像一座古老的被摧毁的城堡塔。
这是另一个示例输入:
6b5b+a6b1-2d+3-4f1-2d+-2c+2-4f+1-2d+-2c2-2d+1-4g+1-2c+b+-2c+-4e2-7j+-4g+d+-2c+-4f2-7j+-5h+b+-2c+a+-3f2-7j+-7i+-4e+b+b+a+-4f2-7i+a+-7h+-4f+b+b+a+-4f2-7j+-7h+-4f+a+-7h+a+-7i+-4f2-7j+-7i+-6h+a+-7i+b+-4e3-7i+a+-7h+-4e+a+-7h+b+1-7h3-7j+1-4f+-7h+b+-4f+a3-7j+2-4f+a+-4f+b3-2d+-2d+3-4g+b3-2d+-2d+-2c
以及结果输出:
****** +++
******+.*++
---++.+ ***
-+-+++..++**
-+--+++.+++*
--++++.+..*
+++++.+**
+++****.****** -
+++*****.**.. --
+ ***....+..--
...+.....--
--.........--
---......
--
(本来应该是马里奥,但结果并不好...)
如果规范还不清楚,我有一个用Python 2.7编写的非高尔夫实现。您可以运行它并进行实验,以了解规范的工作原理。您也可以选择嘲笑我的编程技能。
这是代码高尔夫球,因此最短的参赛作品将获胜。如果不清楚,请在评论中提问。
a+a+a+a+a
将在彼此之上输出五个加号。