Table for all combinatios

ms02kk1

New Member
Joined
Apr 13, 2012
Messages
5
I want to create a table with seven columns that each line will have all the possible combinations in order the sum of the line to be always 1. Each number will increase by 0.1 from 0 to 1. See example below:

C1 C2 C3 C4 C5 C6 C7
1 0 0 0 0 0 0
0.9 0.1 0 0 0 0 0
0.8 0.1 0.1 0 0 0 0
0.7 0.1 0.1 0.1 0 0 0
.
.
.
.
0.3 0.2 0.1 0.1 0.1 0.1 0.1
.
.
.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
If c1 has .9 and c2 has .1 they add to 1
if c1 has .1 and c2 has .9 they also add to 1

Do you want them both listed??
 
Upvote 0
Thare are 8008 such arrangements.

Another way to look at it is to generate all the partitions of 10 that have 7 or fewer elements -- there are a lot fewer of those to stare at:

10
9+1
8+2
8+1+1
7+3
7+2+1
7+1+1+1
6+4
6+3+1
6+2+2
6+2+1+1
6+1+1+1+1
5+5
5+4+1
5+3+2
5+3+1+1
5+2+2+1
5+2+1+1+1
5+1+1+1+1+1
4+4+2
4+4+1+1
4+3+3
4+3+2+1
4+3+1+1+1
4+2+2+2
4+2+2+1+1
4+2+1+1+1+1
4+1+1+1+1+1+1
3+3+3+1
3+3+2+2
3+3+2+1+1
3+3+1+1+1+1
3+2+2+2+1
3+2+2+1+1+1
3+2+1+1+1+1+1
2+2+2+2+2
2+2+2+2+1+1
2+2+2+1+1+1+1

(Divide all the numbers by 10 to get them to add to 1 instead of 10)
 
Upvote 0
This macro will list them as integers summing to 10:


Code:
Sub marine()
Dim I As Long, J As Long, K As Long, L As Long
Dim M As Long, N As Long, O As Long, x As Long
x = 1
For I = 0 To 9
For J = 0 To 9
For K = 0 To 9
For L = 0 To 9
For M = 0 To 9
For N = 0 To 9
For O = 0 To 9
If I + J + K + L + M + N + O = 10 Then
Cells(x, 1) = I
Cells(x, 2) = J
Cells(x, 3) = K
Cells(x, 4) = L
Cells(x, 5) = M
Cells(x, 6) = N
Cells(x, 7) = O
x = x + 1
End If
Next
Next
Next
Next
Next
Next
Next
MsgBox x
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top