It is a long problem ,but quite simple.
"NO HIDDEN TESTCASE" error obtained.
Simple proceedural coding will solve the problem easily.
Further doubts are encouraged and the comments can be used for this purpose.
CODE:
========================================================================
n=int(input())
L=[]
import re
import sys
if(n<=0 or n%2==0):
print("Invalid input")
sys.exit()
while(True):
k=input()
for ch in k:
if(re.match("[^A-Za-z]",ch)):
print("Invalid input")
sys.exit()
if(len(k)==n):
L.append(k)
else:
break
L2=[]
p=len(L)
L2.append(k)
for l in range(n-2):
k=input()
if(len(k)!=p):
print("Invalid input")
sys.exit()
L2.append(k)
for ch in k:
if(re.match("[^A-Za-z]",ch)):
print("Invalid input")
sys.exit()
k=input()
for ch in k:
if(re.match("[^A-Za-z]",ch)):
print("Invalid input")
sys.exit()
c=0
F=[]
for x in range(p):
temp=list(L[x])
for y in range(n-1):
temp.append(L2[y][c])
F.append(temp)
c=c+1
W2=[]
Wv=[]
for j in range(p-1,-1,-1):
W2.append(F[j][0])
Wv.append(j)
for j in range(1,p//2):
W2.append(F[j][j])
Wv.append(j+j)
m=(p-1)//2
for j in range((p//2),-1,-1):
W2.append(F[j][m])
Wv.append(j+m)
m=m+1
for j in range(1,p):
W2.append(F[j][p-1])
Wv.append(j+p-1)
T=sum(Wv)
F2=[]
for p in range(len(Wv)):
temp2=[]
temp3=0
for q in range(p,len(W2)):
temp2.append(W2[q])
temp3=temp3+Wv[q]
if(temp3!=0):
if(T%temp3==0):
TEMP=list(temp2)
F2.append(TEMP)
l3=len(k)
FINAL=[]
for l in F2:
s=''.join(l)
for l2 in range(len(s)-l3+1):
if(s[l2:(l2+l3)]==k):
FINAL.append(s)
break
FINAL.sort()
print(FINAL)
========================================================================
Patel
ReplyDelete;P
Delete