String encoding
A shifted to right by 1 b
If abc shifted to ijk according to input is yes other wise no
def isConversionPossible(s1, s2, x):
s1 = list(s1)
s2 = list(s2)
for i in range(len(s1)):
diff = ord(s2[i]) - ord(s1[i])
if diff == 0:
continue
if diff < 0:
diff = diff + 26
if diff > x:
return False
return True
a = 'abc'
b = 'ijk'
print(('Yes' if isConversionPossible(a, b, 6) else 'No'))
Comments
Leave a comment