25
0
Version 2 here.
Simple challenge: given an integer, draw a house of cards with the given number of stories. If the number is negative, draw the house upside-down. Examples:
Input: 2
Output:
/\
--
/\/\
Input: 5
Output:
/\
--
/\/\
----
/\/\/\
------
/\/\/\/\
--------
/\/\/\/\/\
Input: 0
Output: <empty, whitespace or newline>
Input: -3
Output:
\/\/\/
----
\/\/
--
\/
Input can be numeric or a string. Output must be exactly as shown, with leading and/or trailing spaces and newlines allowed.
This is code-golf, so may the shortest program/function for each language win!
This comes from the sandbox.
– Charlie – 2017-07-10T11:30:47.713Are leading newlines allowed? – Shaggy – 2017-07-10T11:35:10.950
@Shaggy yes, you can also have leading whitespaces and newlines, as long as you draw the house of cards exactly as shown. I don't mind if it is not aligned to the left of the screen. – Charlie – 2017-07-10T11:36:33.853
Can we thrown and error on
input=0
? – Rod – 2017-07-10T11:45:47.470@Rod If that produces empty output it's allowed by default
– Luis Mendo – 2017-07-10T11:47:32.317@Rod if it's allowed by default, I won't complaint then. – Charlie – 2017-07-10T11:50:27.347
@CarlosAlejo managed to work around it c: – Rod – 2017-07-10T11:53:19.853
Radiohead song... – Melkor – 2017-07-11T18:56:36.960