Hello coders, today we are going to solve Triangle Quest HackerRank Solution in Python.
You are given a positive integer N. Print a numerical triangle of height N – 1 like the one below:
1 22 333 4444 55555 ......
Can you do it using only arithmetic operations, a single for loop and print statement?
Use no more than two lines. The first line (the for statement) is already written for you. You have to complete the print statement.
Note: Using anything related to strings will give a score of 0.
A single line containing integer, N.
- 1 <= N <= 9
Print N – 1 lines as explained above.
1 22 333 4444
Solution – Triangle Quest in Python
for i in range(1, int(input())): print((10**(i)//9)*i)
Disclaimer: The above Problem (Triangle Quest) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.
1 thought on “Triangle Quest in Python | HackerRank Solution”
more than two lines of code is not allowed