I choose 2 letters from above 4 letters in 6 combinations using combination formula
n! / r! (n-r)!
array(A, B), array(A, C), array(A, D), array(B, C), array(B, D), array(C, D)
How can I find combinations of groups of 2 or 3 or n (should be dynamic) which do not have letters in common. So I am expecting result to be below combinations for group of 2,
array(A, B), array(C, D)
array(A, C), array(B, D),
array(A, D), array(B, C),
This is just an example but i want the algorithm should work for large number of arrays (I have more than 35000 arrays). I want to find group of 2 or 3 or n (should be dynamic), each group should have arrays which do not have elements in common (all keys should be different, not a single elements should be repeated).