Triangle Quest 2 in Python - HackerRank Solution
Problem :
Your task is to print a palindromic triangle of size N.
For example, a palindromic triangle of size 5 is:
1 121 12321 1234321 123454321
You have to complete the code using exactly one print statement.
Note :
Using anything related to strings will give a score of 0.
Using more than one for-statement will give a score of 0.
Using more than one for-statement will give a score of 0.
Input Format :
A single line of input containing the integer N.
Constraints :
- 0 < N < 10
Output Format :
Print the palindromic triangle of size N as explained above.
Sample Input :
5
Sample Output :
1 121 12321 1234321 123454321
Solution :
1 2 3 4 5 6 7 | # Triangle Quest 2 in Python - Hacker Rank Solution # Python 3 for i in range(1,int(input())+1): #More than 2 lines will result in 0 score. Do not leave a blank line also # Triangle Quest 2 in Python - Hacker Rank Solution START print(((10**i-1)/(9))**2) # Triangle Quest 2 in Python - Hacker Rank Solution END |
Disclaimer :-
the above hole problem statement is given by hackerrank.com but the solution is generated by the codeworld19 authority if any of the query regarding this post or website fill the following contact form thank you.
This comment has been removed by the author.
This is not a correct solution. Try it for any number greater than 8, it gives wrong output. try
for i in range(1,int(input())+1):
print((10**i//9)**2)