Skip to content

Instantly share code, notes, and snippets.

@fluffywaffles
Last active May 11, 2016 09:15
Show Gist options
  • Save fluffywaffles/043b92c285c401bf43a40ec64df36028 to your computer and use it in GitHub Desktop.
Save fluffywaffles/043b92c285c401bf43a40ec64df36028 to your computer and use it in GitHub Desktop.
def recursive_size(s, nodes):
'''
tail recursive size
'''
num = len(nodes)
if (num == 0): return s
children = n.children.values()
return sum([ recursive_size(s + num, children) for n in nodes ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment