Deloitte | COGNIZANT | IBM | CAPGEMINI
def warpedSpell(secret: int) -> int:
def ispalindrome(n):
s = str(n)
length = len(s)
if length > 7:
return 9999999
if length < 4:
return 1001
half = s[:(length + 1) // 2]
candidate = int(half + half[::-1][length % 2:])
if candidate > n:
return candidate
half = str(int(half) + 1)
candidate = int(half + half[::-1][length % 2:])
return candidate
return ispalindrome(secret)
#warpedSpell_q1
#ThoughtWorks
contact:@MLCODER2
906 ·