Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

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
         _/
       _/##
     _/####
   _/######
 _/########
/##########
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

7 answers

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+1
−0

Vyxal jṀ, 11 bytes

ƛd‛_/$꘍⁰d↳Ḣ

Try it Online!

ƛ           # Map 0...n to...
  ‛_/       # '_/'
     $꘍     # And append...
 d          # Double
            # (Implicit input)
     $꘍     # Spaces
         ↳  # Pad to length...
        d   # Double
       ⁰    # Initial input
          Ḣ # Cut of the first character 
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+3
−0

Python 3, 64 bytes

def f(n):
	for i in range(n):print(('  '*(n-i)+'_/'+'##'*i)[3:])

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

Haskell, 78 bytes

(!)0.(*2)
i!n|i<n=(drop 3$(n-i)#' '++"_/"++i#'#'):(i+2)!n|0<1=[]
(#)=replicate

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

Ruby, 50 bytes

->n{n.times{puts ('  '*(n-_1)+'_/'+'##'*_1)[3..]}}

Attempt This Online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Japt -R, 13 bytes

Uses = in place of #.

Æ"_/"+Xç¥ÃoÅù

Try it

Æ"_/"+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
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

JavaScript (Node.js), 91 bytes

(n)=>[...Array(n)].map((_,i)=>console.log(('  '.repeat(n-i)+'_/'+'##'.repeat(i)).slice(3)))

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

Directly using a for loop is less expensive (1 comment)
+1
−0

Stax, 8 bytes

Ç▐GcΦ≡◘¶

Run and debug it

Uses spaces as the staircase fill.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »