Sha256: a4c9600063f269d79d36bf2a8abb284038421a2c02c5223be15d493a3eb10507

Contents?: true

Size: 381 Bytes

Versions: 325

Compression:

Stored size: 381 Bytes

Contents

def check_brackets(string):
    counterparts = {')': '(', '}': '{', ']': '['}

    stack = []
    for char in 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

325 entries across 325 versions & 1 rubygems

Version Path
trackler-2.2.1.107 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.106 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.105 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.104 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.103 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.102 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.101 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.100 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.99 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.98 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.97 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.96 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.95 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.94 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.93 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.92 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.91 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.90 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.89 tracks/python/exercises/bracket-push/example.py
trackler-2.2.1.88 tracks/python/exercises/bracket-push/example.py