Programming up a pattern matching game.
We have 135 symbols. Of those 135, a subset of 108 symbols is used. From the subset of 108, either 18, 21, or 24 symbols are chosen at random. For simplicity, let's stick with 18.
When a symbol is chosen, it can't be used again.
Using groups of 27 symbols at a time, we need to generate the minimum number of groups of 27, making sure that when 18 symbols are chosen at random from the subset of 108, we are guaranteed that 1 of them will match at least 12 other symbols from the 18 randoms in at least 1 of the groups of 27.
Question is, what is the programming logic (we're using C#) to generate the groups of 27 making sure to meet the symbol matching requirements?
If we didn't care about having to match things up, it would be a straight combination/factorial calculation.
Eg, along the lines of: (135 * 134 * 133 * ... * 27) / (27 * 26 * ... * 1)
But am totally stumped on the best approach to fulfil the matching requirements.
Pseudo logic and/or sample code would be greatly appreciated!
EDIT: trying this example as requested. Hopefully it clears things up. Am going to use numbers since it wouldn't be practical to try and upload 135 image symbols.
So let's say our 135 symbols are the numbers 1-135 inclusive. Of those 135 numbers, a subset of 108 is chosen. For simplicity, let's use the numbers 1-108.
Pick 18 random numbers from the subset 1-108: let's use 1-18 inclusive in place of symbols.
We need to come up with the minimum number of groups of 27 symbols (numbers in this example) so that at least one group of 27 (from amongst all our groups of 27), will have at least 12 of the 18 random numbers (symbols).
That is, one group will possibly look like: 1,2,3,5,6,7,77,9,10,13,15,30,40,50,60,70,56,43,100,4,103,99,66,8,78,44,55 as it matches 12 of the 18 random symbols (numbers).
Note that the 18 random symbols are chosen after the groups of 27 are chosen. There can be as many groups of 27 as needed.