Pattern Printing Middle Letter - Odd Length String
Coding Problem Keys
Pattern Printing Middle Letter - Odd Length String
Problem Statement
An odd length string S is passed as the input. The program must print the pattern as described below.
Let L be the length of the string and M denote the middle position of the string S. The characters in the string are a(1),...., a(M), .... a(L).
Note: Asterisk * will be used to pad in the front so that each line has L characters.
Input Format
Output Format
Boundary Condition(s)
Example Input/Output 1
Input
Output
Example Input/Output 2
Input
Output
Note: Max Execution Time Limit: 5000 millisecs
Solution
Programming Language: Python 3 Language
a=input().strip() a=a[len(a)//2:]+a[:len(a)//2] for i in range(1,len(a)+1): print("*"*(len(a)-i),a[:i],sep='')
#Published By PKJCODERS
Alter
n=input().strip();p=1 newstr=n[len(n)//2]+n[len(n)//2+1:]+n[:len(n)//2] for i in range(len(n)-1,-1,-1): print("*"*i+newstr[:p]) p+=1
#Published By PKJCODERS
(Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.)
Comments