Passed
Push — master ( fdd8aa...118bce )
by Ken M.
01:37
created

surjection_strings.isometric_strings()   A

Complexity

Conditions 4

Size

Total Lines 9
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nop 2
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
def isometric_strings(a, b):
2
    mappings = {}
3
    for i, v in enumerate(a):
4
        if v not in mappings:
5
            mappings[v] = b[i]
6
        else:
7
            if mappings[v] != b[i]:
8
                return False
9
    return True
10
11
12
if __name__ == "__main__":
13
    print("Example:")
14
    print(isometric_strings("add", "egg"))
15
16
    # These "asserts" are used for self-checking and not for an auto-testing
17
    assert isometric_strings("add", "egg") == True
18
    assert isometric_strings("foo", "bar") == False
19
    assert isometric_strings("", "") == True
20
    assert isometric_strings("all", "all") == True
21
    assert isometric_strings("gogopy", "doodle") == False
22
    print("Coding complete? Click 'Check' to earn cool rewards!")
23