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.159 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.158 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.157 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.156 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.155 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.154 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.153 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.152 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.151 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.150 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.149 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.148 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.147 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.146 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.145 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.144 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.143 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.142 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.141 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.140 tracks/python/exercises/bracket-push/example.py