You are viewing a single comment's thread. Return to all comments →
Here is Python 3 solution from my HackerrankPractice repository:
for i in range(1, a + 1):
print((a - i) * ' ' + i * "#")
n = int(input())
Feel free to ask if you have any questions :)
Thank you for your answer, but I think there is some wrong with this answers. Because the OUTPUT stairs we want is not very regular. That is if you watch carefully, the right side the stairs does not perfectly in line up. Do you have any other ideas?
I have tried the same, but with comma instead of plus in print call.
actually result looks almost the same, but doesn't pass tests :)
I tried this way in Python3
starthash = n-1
for j in range(0,n):
for i in range(0,n):
if i < starthash:
print (" ",end="")
starthash = starthash -1
I tried doing in one line using List Comprehension and List unpacking:
print([" "(n-i-1) + "#"*(i+1) for i in range(n)], sep='\n')
I think it needs to be:
Doesn't it? The stairs go irregular if it is not.