Count delimiters solution in Clear category for How Deep by kkkkk
"""Return depth of tuples found in structure."""
max_depth = 1
depth = 0
for char in str(structure):
if char in ['(', '[']:
depth += 1
elif char in [')', ']']:
# Determine if this is new deepest level for this
# set of tuples.
max_depth = max(depth, max_depth)
# Reset the depth for the next round of parens
# or brackets.
depth = 1
Aug. 31, 2019