Skip to content

Instantly share code, notes, and snippets.

@stellamiranda
Created June 18, 2017 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stellamiranda/6e416082b97e1b1f63998e9ebc49b892 to your computer and use it in GitHub Desktop.
Save stellamiranda/6e416082b97e1b1f63998e9ebc49b892 to your computer and use it in GitHub Desktop.
Staircase
# Challenge: Staircase - HakerRank
# Author: Stella Miranda
# Consider a staircase of size n = 4:
#
##
###
####
# Observe that its base and height are both equal to n, and the image is drawn using # symbols and spaces.
# The last line is not preceded by any spaces.
# Write a program that prints a staircase of size n.
# Input Format
# A single integer, n, denoting the size of the staircase.
# Output Format
# Print a staircase of size n using # symbols and spaces.
# Note: The last line must have 0 spaces in it.
# Sample Input
# 6
# Sample Output
#
##
###
####
#####
######
n = gets.strip.to_i
n.times do |i|
puts" "*(n-i-1)+"#"*(i+1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment