Hackerrank - Triangle Quest 2 Solution
1 min read

Hackerrank - Triangle Quest 2 Solution

Hackerrank - Triangle Quest 2 Solution

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  as explained above.

Sample Input

5

Sample Output

1
121
12321
1234321
123454321

Solution in Python

for i in range(1,int(input())+1):
    print((10**i//9)**2)

Enjoying these posts? Subscribe for more


Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

That's okay. But without advertising-income, we can't keep making this site awesome.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add thepoorcoder.com to your ad blocking whitelist or disable your adblocking software.

×