All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Marbles in boxes (Posted on 2017-08-16)
How many distinct distributions (x,y,z,w) of n identical marbles in 4 boxes labeled A,B,C and D are there, such that
x,y,z,w are positive integers in strictly increasing order?

Verify the validity of your formula (or set of formulas) by manual listing of all such distributions for n=18.

 No Solution Yet Submitted by Ady TZIDON No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 solution | Comment 2 of 5 |
In mathematical notation:

Sigma{x=1 to floor((n-1)/4)}
Sigma{y=x+1 to floor((n-1-x)/3)}
Sigma{z=y+1 to floor((n-1-x-y)/2)}
1

The algorithm produces

` n distributions10       111       112       213       314       515       616       917       1118       1519       1820       2321       2722       3423       3924       4725       5426       6427       7228       8429       9430       10831       12032       13633       15034       16935       18536       20637       22538       24939       27040       29741       32142       35143       37844       41145       44146       47847       51148       55149       58850       63251       67252       72053       76454       81655       86456       92057       97258       103359       108960       115461       121562       128563       135064       142565       149566       157567       165068       173569       181570       1906`

For n=18 the fifteen distributions are:

1 2 3 12
1 2 4 11
1 2 5 10
1 2 6 9
1 2 7 8
1 3 4 10
1 3 5 9
1 3 6 8
1 4 5 8
1 4 6 7
2 3 4 9
2 3 5 8
2 3 6 7
2 4 5 7
3 4 5 6

The program below uses a, b, c and d instead of x, y, z and w. The same idea. The for statement increments by 1 each time, so it will indeed stop with the floor of the terminal value given.

DefDbl A-Z
Dim crlf\$

Form1.Visible = True

Text1.Text = ""
crlf = Chr\$(13) + Chr\$(10)

For n = 10 To 70
ct = 0
For a = 1 To (n - 1) / 4
For b = a + 1 To (n - a - 1) / 3
For c = b + 1 To (n - a - b - 1) / 2
d = n - a - b - c
ct = ct + 1
Next
Next
Next
Text1.Text = Text1.Text & n & Str(ct) & crlf
Next

Text1.Text = Text1.Text & crlf & " done"

End Sub

1

 Posted by Charlie on 2017-08-16 11:41:37

 Search: Search body:
Forums (0)