How many set could be formed.

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,371
Office Version
  1. 2010
Hello,

Using 4 digit 0,1,2,3 in the row how many set could be formed which sum could be = 14
Note: each single digit can be used 0-to14 times too.

Like this example

0
1
2
3
Sum
14
0
0
0
14
0
4
7
3
14
1
4
5
4
14
1
6
5
2
14
2
4
7
1
14
1
8
2
3
14
1
8
4
1
14
1
7
6
0
14
3
5
5
1
14
2
6
5
1
14
1
9
3
1
14
3
4
6
1
14
2
6
4
2
14
0
14
0
0
14
0
0
14
14
14
0
0
0
14
14

<tbody>
</tbody>


Thank you all
Excel 2000
Regards,
Moti
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I suspect that's the 15th Tetrehedral number which would be 680. You can generate all possible sets like this:

Code:
Public Sub GenerateSets()

Const targetValue = 14

Dim nextRow As Long

Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long

nextRow = 1
For a = 0 To targetValue
    For b = 0 To targetValue - a
        For c = 0 To targetValue - a - b
            d = targetValue - a - b - c
            nextRow = nextRow + 1
            Cells(nextRow, 1) = a
            Cells(nextRow, 2) = b
            Cells(nextRow, 3) = c
            Cells(nextRow, 4) = d
        Next c
    Next b
Next a

End Sub

WBD
 
Upvote 0
I suspect that's the 15th Tetrehedral number which would be 680. You can generate all possible sets like this:

Code:
Public Sub GenerateSets()

Const targetValue = 14

Dim nextRow As Long

Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long

nextRow = 1
For a = 0 To targetValue
    For b = 0 To targetValue - a
        For c = 0 To targetValue - a - b
            d = targetValue - a - b - c
            nextRow = nextRow + 1
            Cells(nextRow, 1) = a
            Cells(nextRow, 2) = b
            Cells(nextRow, 3) = c
            Cells(nextRow, 4) = d
        Next c
    Next b
Next a

End Sub

WBD
Wow! wideboydixon,

This is perfect - thank you very much!

Regards,
Moti :)

 
Upvote 0

Forum statistics

Threads
1,216,030
Messages
6,128,418
Members
449,449
Latest member
Quiet_Nectarine_

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