Can anyone help me with the code for the following question?
UVA Magic Square Palindrome
And this is my code for it. I have got Wrong Answer in it.
import string
from math import sqrt,modfdef trans(s):
p=s.maketrans(string.punctuation+string.ascii_uppercase," "*len(string.punctuation)+string.ascii_lowercase)
return s.translate(p)for test in range(0,int(input())):
matrix=(trans(input())).split()
s=“”.join(matrix)if (modf(sqrt(len(s))))[0]==0: #modf returns (decimal part,integer) if s==s[::-1]: s_left="" for a in range(0,len(matrix)): for b in range(0,len(matrix[a])): s_left+=matrix[a][b] if s_left==s_left[::-1]: print('Case #{}:'.format(test+1)) print(round(sqrt(len(s)))) else: print('Case #{}:'.format(test+1)) print('No magic :(')