Please read the new rule regarding the restriction on the use of AI tools. ×

Prroblem 1093 B

Revision en1, by Puspak-Sahu, 2020-03-20 20:56:50

def goodstr(s): n=len(s) if s.count(s[0])==n: return -1 elif s!=s[::-1]: return s else: m=n//2 j=m+1 while s[m]==s[j]: j+=1 return s[:m]+s[j]+s[m+1:j]+s[m]+s[j+1:]

for i in range(int(input())): print(goodstr(input()))

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Puspak-Sahu 2020-03-20 20:56:50 332 Better solution than one in the tutorial (published)