Created
June 18, 2017 23:34
-
-
Save stellamiranda/6e416082b97e1b1f63998e9ebc49b892 to your computer and use it in GitHub Desktop.
Staircase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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