Puspak-Sahu's blog

By Puspak-Sahu, history, 5 years ago, In English

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()))

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it