Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Count delimiters solution in Clear category for How Deep by kkkkk
def how_deep(structure):
"""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
return max_depth
Aug. 31, 2019