题目:
两个字符串可不可以成某种规律映射
Example:
isometric_strings(‘add’, ‘egg’) == True
isometric_strings(‘foo’, ‘bar’) == False
Precondition:both strings are the same size
链接:
https://py.checkio.org/en/mission/isometric-strings/
def isometric_strings(str1: str, str2: str) -> bool:
r = True
if len(str1) > 1:
for i in range(0, len(str1)-1):
for j in range(i+1, len(str1)):
if str1[i] == str1[j] and str2[i] != str2[j]:
r = False
break
elif str1[i] != str1[j] and str2[i] == str2[j]:
r = False
break
return r
```