Extract that set which passes minimum 3 matches

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Using Excel 2010

Hello,

I got something in net I need an answer my head is broken how it is possible. There is some maths that is far beyond my knowledge.

There are 81 set of 4 numbers in the range C6:F86, out of these 81 sets there are only 9 unique set in the range I1:Q4, if I match these unique 9 with 81 sets there is 100 match of minimum 3 and max 4 match within these 9 sets.

To compare match there is formula in cells I6:Q6 which can be copied to down Q86.

Here is my question how and which formula or VBA has applied to bring these 9 unique those have match minimum 3 and 4 with all 81 combinations. Please help with this odd query.

Match Minimum 3.xls
ABCDEFGHIJKLMNOPQRS
1000111222
2012012012
3012120201
4021102210
5
600004        
700013
800023
900103
1000113
1100123
1200203
1300213
1400223
1501003
1601013
1701023
1801103
1901113
2001124
2101203
2201213
2301223
2402003
2502013
2602023
2702103
2802113
2902123
3002203
3102214
3202223
3310003
3410013
3510023
3610103
3710114
3810123
3910203
4010213
4110223
4211003
4311013
4411023
4511103
4611113
4711123
4811204
4911213
5011223
5112003
5212013
5312024
5412103
5512113
5612123
5712203
5812213
5912223
6020003
6120013
6220023
6320103
6420113
6520123
6620203
6720213
6820224
6921003
7021014
7121023
7221103
7321113
7421123
7521203
7621213
7721223
7822003
7922013
8022023
8122104
8222113
8322123
8422203
8522213
8622223
87
88
Sheet1
Cell Formulas
RangeFormula
I6:Q6I6=IF(SUMPRODUCT(--($C6:$F6=TRANSPOSE(I$1:I$4)))>2,SUMPRODUCT(--($C6:$F6=TRANSPOSE(I$1:I$4))),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I6:Q86Cell Value=4textYES


Thank you.

Regards,
Moti
 
It sounds like you're trying to understand the SUMPRODUCT formula. I'll try to explain what's going on with one of them, and I think the rest of the formula will come together for you after that.

This is used twice, and only shown if it's greater than 2:
Excel Formula:
=SUMPRODUCT(--($C6:$F6=TRANSPOSE(I$1:I$4))

Transpose just takes the horizontal I1:I4 and makes it vertical, like the C6:F6 is vertical.
Now that they're both vertical, the next part of the formula gives you a series of True or False answers, so
( C6:F6 = I1:I4 ) --> ( C6=I1, D6=I2, E6=I3, F6=I4) --> (TRUE, TRUE, TRUE, TRUE)

Now you want to add up which ones are true, which is where the "double-unary" comes into play. When you apply math to a TRUE or FALSE answer in Excel, Excel makes TRUE = 1, and FALSE = 0. The double negative (--) just turns them to negative numbers and back to positive numbers again. So now:

--(TRUE, TRUE, TRUE, TRUE) --> (1, 1, 1, 1)

That gets fed into SUMPRODUCT, which just adds those numbers together to make 4.

The rest of the formula is just making sure it's greater than 2 before actually showing it.
 
Upvote 0
It sounds like you're trying to understand the SUMPRODUCT formula. I'll try to explain what's going on with one of them, and I think the rest of the formula will come together for you after that.

This is used twice, and only shown if it's greater than 2:
Excel Formula:
=SUMPRODUCT(--($C6:$F6=TRANSPOSE(I$1:I$4))

Transpose just takes the horizontal I1:I4 and makes it vertical, like the C6:F6 is vertical.
Now that they're both vertical, the next part of the formula gives you a series of True or False answers, so
( C6:F6 = I1:I4 ) --> ( C6=I1, D6=I2, E6=I3, F6=I4) --> (TRUE, TRUE, TRUE, TRUE)

Now you want to add up which ones are true, which is where the "double-unary" comes into play. When you apply math to a TRUE or FALSE answer in Excel, Excel makes TRUE = 1, and FALSE = 0. The double negative (--) just turns them to negative numbers and back to positive numbers again. So now:

--(TRUE, TRUE, TRUE, TRUE) --> (1, 1, 1, 1)

That gets fed into SUMPRODUCT, which just adds those numbers together to make 4.

The rest of the formula is just making sure it's greater than 2 before actually showing it.
Hello Vogateer, thank you for explaining SUMPRODUCT formula in detail.

But I need if you look in the column C, D, E and F there are 81 combinations vertically with set of 4. And In horizontal range I1:Q4 there are 9 combinations with set of 4…is it correct?

I want to know how these 8 horizontal range I1:Q4 combinations has extracted from 81 which has minimum match with 3 and 4…..you think in other way I don’t have these 9 horizontal range I1:Q4 combinations and I want to pull out from 81…how it could be done? :unsure:

I am sure they are not selected randomly is it correct
?

Good Luck

Regards,
Moti
 
Upvote 0
I think I am confused about what you want. Are you saying that you want to come up with the I6:Q86 numbers without using the I1:Q4 numbers above? If not, maybe you could help me understand what numbers and cell addresses you would have to start, then what the final result might look like.
 
Upvote 0
I think I am confused about what you want. Are you saying that you want to come up with the I6:Q86 numbers without using the I1:Q4 numbers above? If not, maybe you could help me understand what numbers and cell addresses you would have to start, then what the final result might look like.
Have another look as I put 9 set of 4 in Range I2:Q5 that has created confusion…

Here is a revised question suppose now we have 81 set only in columns “C:F” of 4 in 4…as 0000, 0001,0002…so on, and nothing in the Range I2:Q5…is it clear till here.

Now I want out of 81 extract only those unique set which give me matches of 3 and 4 with each of 81 sets as shown in the range I7:Q87. how could this be find and done?

Match Minimum 3.xls
ABCDEFGHIJKLMNOPQRS
1Set1Set2Set3Set4Set5Set6Set7Set8Set9
2?????????
3?????????
4?????????
5?????????
6
70000Match 4------>4
80001Match 3------>3
90002Match 3------>3
100010Match 3------>3
110011Match 3------>3
120012Match 3------>3
130020Match 3------>3
140021Match 3------>3
150022Match 3------>3
160100Match 3------>3
170101Match 3------>3
180102Match 3------>3
190110Match 3------>3
200111Match 3------>3
210112Match 4------>4
220120Match 3------>3
230121Match 3------>3
240122Match 3------>3
250200Match 3------>3
260201Match 3------>3
270202Match 3------>3
280210Match 3------>3
290211Match 3------>3
300212Match 3------>3
310220Match 3------>3
320221Match 4------>4
330222Match 3------>3
341000Match 3------>3
351001Match 3------>3
361002Match 3------>3
371010Match 3------>3
381011Match 4------>4
391012Match 3------>3
401020Match 3------>3
411021Match 3------>3
421022Match 3------>3
431100Match 3------>3
441101Match 3------>3
451102Match 3------>3
461110Match 3------>3
471111Match 3------>3
481112Match 3------>3
491120Match 4------>4
501121Match 3------>3
511122Match 3------>3
521200Match 3------>3
531201Match 3------>3
541202Match 4------>4
551210Match 3------>3
561211Match 3------>3
571212Match 3------>3
581220Match 3------>3
591221Match 3------>3
601222Match 3------>3
612000Match 3------>3
622001Match 3------>3
632002Match 3------>3
642010Match 3------>3
652011Match 3------>3
662012Match 3------>3
672020Match 3------>3
682021Match 3------>3
692022Match 4------>4
702100Match 3------>3
712101Match 4------>4
722102Match 3------>3
732110Match 3------>3
742111Match 3------>3
752112Match 3------>3
762120Match 3------>3
772121Match 3------>3
782122Match 3------>3
792200Match 3------>3
802201Match 3------>3
812202Match 3------>3
822210Match 4------>4
832211Match 3------>3
842212Match 3------>3
852220Match 3------>3
862221Match 3------>3
872222Match 3------>3
88
89
90
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I7:Q87Cell Value=4textYES


Good Luck

Regards,
Moti
 
Upvote 0
So, the final step is to find "4" in the range I7:Q87. If found, then copy the 4 cells to the left into the 4 cells above, right?
For example, Set 2, columns J, and the number 4 is found in row 21, we would copy the range C21:F21 (0,1,1,2) into the range J2:J5.
Then, number "3" will be ignored.
Is that right?
 
Upvote 0
So, the final step is to find "4" in the range I7:Q87. If found, then copy the 4 cells to the left into the 4 cells above, right?
For example, Set 2, columns J, and the number 4 is found in row 21, we would copy the range C21:F21 (0,1,1,2) into the range J2:J5.
Then, number "3" will be ignored.
Is that right?
Hello bebo021999, thank you for your interest and asking a question.

Now here is a final layout where I got only 81 set of 4 numbers in the each row and in the range I7:Q87….if I match 81 against 81 we defiantly will find max 4 matches in the each row is it correct?

What is here challenge find among 81 set only those unique set which has minimum match of 3 at least for sure with each set once as per opening post results, if match are below the 3 will be ignored or if more in each row matches also will be ignored….

Match Minimum 3.xls
ABCDEFGHIJKLMNOPQRS
1Set1Set2Set3Set4Set5Set6Set7Set8Set9
2?????????
3?????????
4?????????
5?????????
6
70000
80001
90002
100010
110011
120012
130020
140021
150022
160100
170101
180102
190110
200111
210112
220120
230121
240122
250200
260201
270202
280210
290211
300212
310220
320221
330222
341000
351001
361002
371010
381011
391012
401020
411021
421022
431100
441101
451102
461110
471111
481112
491120
501121
511122
521200
531201
541202
551210
561211
571212
581220
591221
601222
612000
622001
632002
642010
652011
662012
672020
682021
692022
702100
712101
722102
732110
742111
752112
762120
772121
782122
792200
802201
812202
822210
832211
842212
852220
862221
872222
88
89
Sheet3
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I7:Q87Cell Value=4textYES


As massage exceed…continue into next post…
 
Upvote 0
Now we selected one example if we place formula in range I7:Q87 and select 9 random from range C7:Q87… which are highlighted in yellow and paste them in to I2:Q5…look at the result in range I7:Q87…rows I9:Q9, I18:Q18 and more are highlighted in green remain empty. And also find multiple matches in some rows which are highlighted in blue…so far it is not valid selection….look at the example below…..

This is interesting to find unique sets which must have only max 1 match of 3 or 4 against each row are in the range C7:F87…. As you can see in #post1 this is really bit tricky and difficult.

Match Minimum 3.xls
ABCDEFGHIJKLMNOPQRS
1Set1Set2Set3Set4Set5Set6Set7Set8Set9
2000111222
3012012011
4211110002
5012222102
6
700003        
800013
90002
1000103
1100113
12001233
1300204
1400213
1500223
1601003
1701013
180102
1901103
2001114
210112333
2201203
2301213
2401223
250200
260201
27020233
2802103
29021133
3002124
3102203
320221
3302223
341000
3510013
36100233
3710103
3810113
39101243
4010203
411021
4210223
4311003
441101
45110233
4611103
47111133
48111234
491120
501121
51112233
5212003
5312013
5412024
551210
561211
5712123333
581220
591221
6012223
61200033
6220014
6320023
642010
6520113
6620123
6720203
6820213
6920223
7021004
71210133
72210233
7321103
7421113
75211233
76212033
7721213
7821224
7922003
8022013
8122023
822210
832211
8422123
852220
862221
8722223
88
89
Sheet4
Cell Formulas
RangeFormula
I7:Q7I7=IF(SUMPRODUCT(--($C7:$F7=TRANSPOSE(I$2:I$5)))>2,SUMPRODUCT(--($C7:$F7=TRANSPOSE(I$2:I$5))),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I7:Q87Cell Value=4textYES


Good Luck

Regards,
Moti
 
Upvote 0
I believe I understand now, you want to generate 9 numbers in I2:Q5, but do so in a way that all 81 numbers in C7:F87 have at least a 3 number match with one of those 9 numbers. Is this for a practical problem you're trying to solve, or are you just interested in algorithms and formulas for the fun of it?

I'm sorry but I don't think I'm going to be able to help here.
 
Upvote 0
I believe I understand now, you want to generate 9 numbers in I2:Q5, but do so in a way that all 81 numbers in C7:F87 have at least a 3 number match with one of those 9 numbers. Is this for a practical problem you're trying to solve, or are you just interested in algorithms and formulas for the fun of it?

I'm sorry but I don't think I'm going to be able to help here.
Hello Vogateer, you got exactly correct my view point, in brief you have explained perfectly which I were not able to explain, this will help programmers to understand better.

Really when I got this I tried to solve but I could not how intelligently someone has come up with only 9 that have at least 3 matches with whole sequence I like excel too much and I am curious to have some VBA or Formula to get these strange results.

When I saw COMBIN(81,9) = 260.887.834.350 set of 9, do you think the person who has come up with this solution checking all these one by one so much combinations?

I also find it is complicate there could be some complex algorithms to find them.

I really appreciate your interest and nice reply which is easy to understand view point for everyone.

I hope someone defiantly will solve this complex task.

Good Luck

Regards,
Moti :)
 
Upvote 0

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