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