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

Comments on Stairs? Stairs! Stairs.

Parent

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

Post
+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)
Directly using a for loop is less expensive
Moshi‭ wrote about 3 years ago

It's better just to use a for loop instead of an expensive [...Array(n)].map((_,i)=>

(n,i=n)=>{for(;i;)console.log(('  '.repeat(i)+'_/'+'##'.repeat(n-i--)).slice(3))}

https://tio.run/##bctBCsIwEEDRfU8R6GJmqInQQDclnkSQEBOJhElJSjfi2SN2IQpu/@Pf7WarK3FZJeerb8E05EM0TOb0CLngHGdymWtOXqV8QwQhQBW/eLtipAEuRxig7z@NZZSSSNUUnUdN9GzfP7AwYgTqAo7U/ciZ36Z3039t2m2i9gI