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.139 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.138 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.137 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.136 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.135 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.134 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.133 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.132 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.131 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.130 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.129 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.128 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.127 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.126 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.125 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.124 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.123 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.122 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.121 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.120 tracks/python/exercises/bracket-push/example.py