Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Speedy category for Surjection Strings by swagg010164
def isometric_strings(str1: str, str2: str) -> bool:
alphabet = {}
for i in range(len(str1)):
if str1[i] in alphabet:
if alphabet.get(str1[i]) != str2[i]:
return False
else:
alphabet[str1[i]] = str2[i]
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!")
Jan. 27, 2019