Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 485 Bytes

draw_stairs.md

File metadata and controls

33 lines (27 loc) · 485 Bytes

Description

Given a number n, draw stairs using the letter "I", n tall and n wide, with the tallest in the top left.

For example n = 3 result in:

"I\n I\n I"

or printed:

I
 I
  I

Another example, a 7-step stairs should be drawn like this:

I
 I
  I
   I
    I
     I
      I

My Solution

def draw_stairs(n)
  n.times.map { |el| "#{ ' ' * el }I" }.join("\n")
end