Answer to Question #303441 in Python for Sai

Question #303441

String encoding



A shifted to right by 1 b



If abc shifted to ijk according to input is yes other wise no




1
Expert's answer
2022-02-28T01:05:51-0500
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'))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS