Triangle Quest 2 in Python HackerRank Solution

Hello Programmers, In this post, you will know how to solve the Triangle Quest 2 in Python HackerRank Solution. This problem is a part of the HackerRank Python Programming Series.

Ezoicreport this adTriangle Quest 2 in Python HackerRank Solution
Triangle Quest 2 in Python HackerRank Solutions

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.

Triangle Quest 2 in Python HackerRank Solutions

Ezoicreport this adproblem

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.
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.

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

Triangle Quest 2 in Python HackerRank Solutions

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) ** 2 // 81)

Disclaimer: The above Problem (Triangle Quest 2 in Python) is generated by Hackerrank but the Solution is Provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.

Next: Mod Divmod in Python HackerRank Solution

Sharing Is Caring

Leave a Comment

Ezoicreport this ad