Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Surjection Strings by PetrStar
def isometric_strings(str1: str, str2: str) -> bool:
d = dict()
for index, ch in enumerate(str1):
if ch in d.keys():
if d[ch] != str2[index]:
return False
else:
d[ch] = str2[index]
return True
if __name__ == '__main__':
print("Example:")
print(isometric_strings('add', 'egg'))
# These "asserts" are used for self-checking and not for an auto-testing
assert isometric_strings('add', 'egg') == True
assert isometric_strings('foo', 'bar') == False
assert isometric_strings('', '') == True
assert isometric_strings('all', 'all') == True
print("Coding complete? Click 'Check' to earn cool rewards!")
Nov. 28, 2020