-
StaircaseEngineering WIKI/HackerRank 2021. 1. 17. 20:55
Staircase detail
This is a staircase of size :
# ## ### ####
Its base and height are both equal to . It is drawn using # symbols and spaces. The last line is not preceded by any spaces.
Write a program that prints a staircase of size .
Function Description
Complete the staircase function in the editor below.
staircase has the following parameter(s):
- int n: an integer
Print
Print a staircase as described above.
Input Format
A single integer, , denoting the size of the staircase.
Constraints
.
Output Format
Print a staircase of size using # symbols and spaces.
Note: The last line must have spaces in it.
Sample Input
6
Sample Output
# ## ### #### ##### ######
#!/bin/python3 import math import os import random import re import sys # Complete the staircase function below. def staircase(n): num = n check_space = " " check_sharp = "#" for index, i in enumerate(range(1, n+1)): space = check_space * (num - i) sharp = check_sharp * i print(str(space) + str(sharp)) if __name__ == '__main__': n = int(input()) staircase(n)
'Engineering WIKI > HackerRank' 카테고리의 다른 글
Time Conversion (0) 2021.01.17 Birthday Cake Candles (0) 2021.01.17 Mini-Max Sum (0) 2021.01.17 Plus Minus (0) 2021.01.17 Diagonal Difference (0) 2021.01.17 A Very Big Sum (0) 2021.01.17 Compare the Triplets (0) 2021.01.17 Simple Array Sum (0) 2021.01.17