Skip to content

Instantly share code, notes, and snippets.

@irachex

irachex/test.py

Last active Dec 13, 2015
Embed
What would you like to do?
cnt = {}
MAX_DEP = 10
def traverse(dep, i, size):
cnt[i] = cnt.get(i, 0) + 1
if dep >= MAX_DEP: return
for j in range(size):
traverse(dep + 1, i + j + 1, size + 1 - j)
traverse(0, 0, 1)
for i in range(8):
print i, cnt[i]
@irachex

This comment has been minimized.

Copy link
Owner Author

@irachex irachex commented Feb 15, 2013

traverse(dep, i, size)表示遍历深度为dep,节点值为i,子节点数为size的节点

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment