#Get the given strings S1 and S2
s1=input("")
s2=input("")
numberRotation =0
tmp=s1
NoMatch=False
#Check two strings
while tmp!=s2:
numberRotation+=1
#Right rotation
tmp = s1[len(s1) - numberRotation:] + s1[0 : len(s1) - numberRotation]
if(numberRotation>=len(s1)):
tmp=s2
NoMatch=True
#If string S2 is a rotation of another string S1,
#print number of right rotations made by string
#S1 to match the string S2. Otherwise, print "No Match".
if NoMatch:
print("No Match")
else:
print(str(numberRotation))
Comments
Leave a comment