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