Skip to content

Instantly share code, notes, and snippets.

@irachex
Last active December 13, 2015 19:09
Show Gist options
  • Select an option

  • Save irachex/4960941 to your computer and use it in GitHub Desktop.

Select an option

Save irachex/4960941 to your computer and use it in GitHub Desktop.

Revisions

  1. irachex revised this gist Feb 15, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion test.py
    Original file line number Diff line number Diff line change
    @@ -9,5 +9,5 @@ def traverse(dep, i, size):

    traverse(0, 0, 1)

    for i in range(10):
    for i in range(8):
    print i, cnt[i]
  2. irachex created this gist Feb 15, 2013.
    13 changes: 13 additions & 0 deletions test.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    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(10):
    print i, cnt[i]