Pattern Printing - X to Y Forward and Reverse

 Coding Problem Keys 

 Pattern Printing - X to Y Forward and Reverse 

 Problem Statement 

The program must accept the integers X and Y and print the pattern as shown in Example Input/Output.

 Boundary Condition(s) 

1 <= X, Y <= 100

 Input Format 

The first line contains X, Y each separated by a space.

 Output Format 

The pattern as explained in the Example Input/Output section.

 Example Input/Output 1 

 Input 

1 5

 Output 

12345
11345
11145
11115
12355
12555
15555

 Example Input/Output 2 

 Input 

3 9

 Output 

3456789
3356789
3336789
3333789
3333389
3333339
3456799
3456999
3459999
3499999
3999999

 Note: Max Execution Time Limit: 5000 millisecs 

 Solution 

 Programming Language: Python 3 Language 

x,y=map(int,input().split())
for i in range(x+1,y+1):
    for j in range(x,i):
        print(x,end="")
    for j in range(i,y+1):
        print(j,end="")
    print()
count=2
for i in range(x,y-1):
    for j in range(x,y-count+1):
        print(j,end="")
    for j in range(count):
        print(y,end="")
    count+=1
    print()

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Toggle Consonants Adjacent to Vowels

String Pattern - Inverted U

Top Scoring Batsman - TEST ODI 20-20

Desktop Products

Mango Distribution

Java - Method Overriding - Area

Microsoft