Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
dict solution in Clear category for Surjection Strings by pokryshkin
def isometric_strings(str1: str, str2: str) -> bool:
d = dict(zip(list(str1), list(str2))) # to make a dict from letters from both strings str1 = keys, str2 = values
answer = ( str2 == ''.join([d[x] for x in str1]) ) # to compare "decoded" str1 with str2
return answer
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 3, 2021
Comments: