版本2 在这里。
简单的挑战:给定一个整数,用给定数目的故事画一张纸牌屋。如果数字为负,则将房子上下颠倒。例子:
Input: 2
Output:
/\
--
/\/\
Input: 5
Output:
/\
--
/\/\
----
/\/\/\
------
/\/\/\/\
--------
/\/\/\/\/\
Input: 0
Output: <empty, whitespace or newline>
Input: -3
Output:
\/\/\/
----
\/\/
--
\/
输入可以是数字或字符串。输出必须与显示的完全一样,并允许前导和/或尾随空格和换行符。
这是代码高尔夫球,因此每种语言中最短的程序/功能可能会获胜!
这来自沙盒。
—
查理
允许换行符吗?
—
毛茸茸的
@Shaggy是的,只要您完全按照所示绘制纸牌屋,您还可以使用领先的空格和换行符。我不在乎它是否未与屏幕左侧对齐。
—
查理
我们可以抛出错误
—
罗德
input=0
吗?
@Rod如果产生空输出,默认情况下
—
Luis Mendo