Sha256: 2503d36351b1f2f0522125af2d0130a62f6b1f0f64e303b28f391e2045ea5ad1

Contents?: true

Size: 388 Bytes

Versions: 71

Compression:

Stored size: 388 Bytes

Contents

def is_paired(input_string):
    counterparts = {')': '(', '}': '{', ']': '['}

    stack = []
    for char in input_string:
        if char in counterparts.values():
            stack.append(char)
        elif char in counterparts:
            if not stack:
                return False
            if stack.pop() != counterparts[char]:
                return False
    return not stack

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.179 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.178 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.177 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.176 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.175 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.174 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.173 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.172 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.171 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.170 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.169 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.167 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.166 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.165 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.164 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.163 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.162 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.161 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.160 tracks/python/exercises/bracket-push/example.py