Skip to content

Instantly share code, notes, and snippets.

@pontikos
Created March 10, 2015 13:43
Show Gist options
  • Save pontikos/4f74862315dee25dac49 to your computer and use it in GitHub Desktop.
Save pontikos/4f74862315dee25dac49 to your computer and use it in GitHub Desktop.
Bars and stars algorithm with three bins. Goal is to extend to N bins. If anyone has any ideas?
# bars and stars algorithm
N=5
for n in range(0,N):
x=[1]*n
for i in range(0,(len(x)+1)):
for j in range(i,(len(x)+1)):
print 100-n, sum(x[0:i]), sum(x[i:j]), sum(x[j:len(x)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment