我喜欢ascii艺术,我很无聊,所以我找到了一些ascii的角色,开始做一些随机的东西,8位马里奥城堡,迷宫和拱门。我发现拱门可以很容易地整齐地堆放起来。
╔═══════╗
║╔═════╗║
║║╔═══╗║║
║║║╔═╗║║║
╨╨╨╨─╨╨╨╨创建一个程序、函数或任何其他标准格式,该格式接受大于或等于0的整数(除非您正在进行奖励),并以指定的拱数输出ascii艺术。
输入:
7输出:
╔═════════════╗
║╔═══════════╗║
║║╔═════════╗║║
║║║╔═══════╗║║║
║║║║╔═════╗║║║║
║║║║║╔═══╗║║║║║
║║║║║║╔═╗║║║║║║
╨╨╨╨╨╨╨─╨╨╨╨╨╨╨备选案文:
+-------------+
|+-----------+|
||+---------+||
|||+-------+|||
||||+-----+||||
|||||+---+|||||
||||||+-+||||||
||||||| |||||||
---------------输入:
1输出:
╔═╗
╨─╨备选案文:
+-+
| |
---+-+代替╔═╗,使用---代替╨─╨,使用|代替║-10%如果程序支持负数并像这样翻转拱门
╥╥╥╥─╥╥╥╥
║║║╚═╝║║║
║║╚═══╝║║
║╚═════╝║
╚═══════╝发布于 2016-01-11 01:27:13
qi:Lg"^Za"a{_0=1'Z3*tsa\{'[2*\*}%+}L(*'rL*a2*N*a+9462ff+N**在这里试试!
发布于 2016-01-11 00:15:19
n=input();j=1
exec"s=j/2*'║';print s+'╔'+'═'*(2*n-j)+'╗'+s;j+=2;"*n
if n:t='╨'*n;print t+'─'+t相当直截了当。用变化的水平和垂直条数逐行打印。最后一行分别打印。
我觉得我错过了一些优化。字符是多个字节的事实意味着您不能执行类似'║╨'[n>0]的操作,所以我没有找到一种很好的方法来打印循环中的最后一行。柜台上有这么多操纵操作,真是太丑了。我希望直接更新字符串,比如s+='║',但是索引也用于水平条。
发布于 2018-07-11 09:36:45
-R,29字节使用+ & -。牺牲了4个字节来处理血腥的输入验证!
©Æ'+²¬q-p´UÑÄÃpS û| p-pNÑÄ)ªP :Implicit input of integer U
© :Logical AND with U
Æ :Map the range [0,U)
'+ : Literal "+"
² : Repeat twice
¬ : Split
q : Join with
- : Literal "-"
p : Repeat
´U : Decrement U
Ñ : Multiply by 2
Ä : Add 1
à :End mapping
pS :Push a space
û| :Centre pad each element with "|" to the length of the longest element
p ) :Push
- : Literal "-"
p : Repeat
N : The array of inputs (which will be cast to an integer if we perform a mathematical operation on it)
ÑÄ : Multiply by 2 and add 1
ª :Logical OR
P :The empty string
:Implicitly join with newlines and outputhttps://codegolf.stackexchange.com/questions/69094
复制相似问题