- You are given a positive integer N.
- 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 can't take more than two lines. The first line (a for-statement) is already written for you.
- Using anything related to strings will give a score of 0.
- Using more than one for-statement will give a score of 0.
- A single line of input containing the integer N.
- 0 < N < 10
- Print the palindromic triangle of size N as explained above.
5
Sample Output:
1
121
12321
1234321
123454321
Solution:
for i in range(1,int(input())+1): #More than 2 lines will result in 0 score. Do not leave a blank line also
print(((10**i - 1)//9)**2)
Disclaimer: The problem statement is given by hackerrank.com but the solution is generated by the Geek4Tutorial admin. If there is any concern regarding this post or website, please contact us using the contact form. Thank you!
No comments:
Post a Comment