String Pattern - Inverted U
Coding Problem Keys
String Pattern - Inverted U
Problem Statement
Three strings S1, S2 and S3 are passed as the input. The program must print the pattern as shown in the Example Input/Output section. Out of these three strings, the two strings that are print along the left most column and the right most column will be of the same length. The string printed along the first row may or may not be equal in length to the other two strings but it's first character will be same as the first character of the string in the left most column and it's last character will be as same as the first character of the string in the right most column. The string values appearing on the top, left, right can appear in any order in the input.
Boundary Condition(s)
Input Format
Output Format
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,b,c=input().strip(),input().strip(),input().strip() if len(a)==len(b) and len(a)==len(c): if a[0]==c[0] and a[-1]==b[0]: b,c=c,b elif b[0]==a[0] and b[-1]==c[0]: a,b=b,a elif b[0]==c[0] and b[-1]==a[0]: a,b,c=b,c,a elif c[0]==b[0] and c[-1]==a[0]: a,c=c,a elif c[0]==a[0] and c[-1]==b[0]: a,b,c=c,a,b elif len(a)==len(b): a,c=c,a elif len(a)==len(c): a,b=b,a if not (len(a)==len(b) and len(b)==len(c)): if a[0]!=b[0]: b,c=c,b print(a) for i,j in zip(b[1:],c[1:]): print(i+'*'*(len(a)-2)+j)# Published By PKJCODERS
(Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.)
Comments