Saturday, September 2, 2017

Pattern Printing - Till N & Reverse

The program must accept an integer N and print 2N lines as shown in the Example Input/Output.

Input Format:
The first line contains N.

Output Format:
2N lines as shown in the Example Input/Output.

Boundary Conditions:
2 <= N <= 100

Example Input/Output 1:
Input:
7
Output:
1
22
333
4444
55555
666666
7777777
7777777
666666
55555
4444
333
22
1

Solution:
n=int(input())
for i in range(2*n):
    i = n-i%n if i>=n else i+1

    print(str(i)*i)
Share: