Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Everybody loves Raymond solution in Clear category for Tree Walker by veky
def tree_walker(tree, target):
if tree == target: return 1
if isinstance(tree, (int, str)): return 0
if isinstance(tree, dict): return tree_walker(tree.values(), target)
return sum(tree_walker(branch, target) for branch in tree)
Nov. 30, 2019
Comments: