Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Dictionary of character correspondence table solution in Clear category for Surjection Strings by keromage
def isometric_strings(str1: str, str2: str) -> bool:
# dic : Dictionary of character correspondence table
dic = {str1[i]: str2[i] for i in range(len(str1))}
# If the string structure of srt1 and str2 is different,
# the string in which each character of str1 is replaced
# in the correspondence table is different from str2.
return ''.join([dic[j] for j in str1]) == str2
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!")
Sept. 16, 2020
Comments: