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

surjection_strings   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 4

1 Function

Rating   Name   Duplication   Size   Complexity  
A isometric_strings() 0 9 4
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