def entry(s1, s2):
s1 = s1.lower()
s1 = s1.replace(" ", "")
s2 = s2.lower()
s2 = s2.replace(" ", "")
isAnagram = False
permutationHistory = list()
while not isAnagram:
stringLength = len(s1)
areStringsEqual = True
if not stringLength == len(s2):
areStringsEqual = False
characterPosition = 0
while areStringsEqual and characterPosition < stringLength:
if not s1[characterPosition] == s2[characterPosition]:
areStringsEqual = False
characterPosition = characterPosition + 1
if areStringsEqual == True:
isAnagram = True
if s1 in permutationHistory:
isAnagram = False
break
permutationHistory.append(s1)
temporaryString = ""
characterPosition = 1
while characterPosition < stringLength:
temporaryString = temporaryString + s1[characterPosition]
characterPosition = characterPosition + 1
temporaryString = temporaryString + s1[0]
s1 = temporaryString
"""if isAnagram == True:
return True
else:
return False"""
# I was originally going to use the above but then I found this easier method on Google.com.
return sorted(s1) == sorted(s2)
post a comment