Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Concise algorithm solution in Speedy category for Surjection Strings by Igor_Sekretarev
def isometric_strings(str1: str, str2: str) -> bool:
transform = {}
for ch1, ch2 in zip(str1, str2):
if ch1 in transform and transform[ch1] != ch2:
return False
transform[ch1] = ch2
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!")
April 25, 2021
Comments: