Skip to content

Instantly share code, notes, and snippets.

@d2207197
Created June 25, 2014 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d2207197/de86fa5613df6e7a8d7f to your computer and use it in GitHub Desktop.
Save d2207197/de86fa5613df6e7a8d7f to your computer and use it in GitHub Desktop.
def split_balls(total, splits):
print total, splits
if splits == 1:
yield (total,)
else:
for i in range(1, total):
for subs in split_balls(total -i, splits -1):
yield (i, ) + subs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment