You are viewing a single comment's thread. Return to all comments →
Range and map is more ruby-esque:
def staircase(n)
(1..n).map{|x| "#{' ' * (n - x)}#{'#' * x}"}.join("\n") + "\n"
end
n = gets.to_i
puts(staircase n)
Seems like cookies are disabled on this browser, please enable them to open this website
Staircase
You are viewing a single comment's thread. Return to all comments →
Range and map is more ruby-esque:
def staircase(n)
(1..n).map{|x| "#{' ' * (n - x)}#{'#' * x}"}.join("\n") + "\n"
end
n = gets.to_i
puts(staircase n)