Stairs? Stairs! Stairs.
+1
−0
Challenge
- Make a program that takes input of an integer that's $n > 1$ and print out a staircase using a specific character for stair basing (hashes (
#
) for demonstration; you can use spaces, but not tabs or other whitespace characters), slashes (/
), and underscores (_
). - The basis of the staircase is having the hashes as to act like the stair supporters, in other words, bricks. The bottom stair starts with a slash then as we go higher, an underscore at the spot right next and above the
- Shortest program in each language wins!
Test Cases
n = 2
_/
/##
n = 3
_/
_/##
/####
n = 6
_/
_/##
_/####
_/######
_/########
/##########
+3
−0
[Python 3], 64 bytes ```pyt …
3y ago
+2
−0
Ruby, 50 bytes ->n{n.tim …
3y ago
+2
−0
[Haskell], 78 bytes …
3y ago
+1
−0
Vyxal `jṀ`, 11 bytes ``` ƛ …
3y ago
+1
−0
[JavaScript (Node.js)], 91 byt …
3y ago
+1
−0
Stax, 8 bytes Ç▐GcΦ≡◘¶ …
3y ago
+1
−0
Japt `-R`, 13 bytes Uses `= …
3y ago
7 answers
+3
−0
+2
−0
+2
−0
Haskell, 78 bytes
(!)0.(*2)
i!n|i<n=(drop 3$(n-i)#' '++"_/"++i#'#'):(i+2)!n|0<1=[]
(#)=replicate
0 comment threads
+1
−0
Japt -R
, 13 bytes
Uses =
in place of #
.
Æ"_/"+Xç¥ÃoÅù
Æ"_/"+Xç¥ÃoÅù :Implicit input of integer U
Æ :Map each X in the range [0,U)
"_/" : Literal string
+ : Append
Xç : X times repeat
¥ : "=="
à :End map
o :Modify last element
Å : Slice off first character
ù :Left pad each with spaces to the length of the longest
:Implicit output joined with newlines
0 comment threads
+1
−0
JavaScript (Node.js), 91 bytes
(n)=>[...Array(n)].map((_,i)=>console.log((' '.repeat(n-i)+'_/'+'##'.repeat(i)).slice(3)))
+1
−0
Vyxal jṀ
, 11 bytes
ƛd‛_/$꘍⁰d↳Ḣ
ƛ # Map 0...n to...
‛_/ # '_/'
$꘍ # And append...
d # Double
# (Implicit input)
$꘍ # Spaces
↳ # Pad to length...
d # Double
⁰ # Initial input
Ḣ # Cut of the first character
0 comment threads