0
$\begingroup$

I need to find a value within the result matrix of combinations of multiple set of elements.

For example using these sets of elements:

W = {apple, grape, lemon}
X = {black}
Y = {square, circle}
Z = {dog, cat}

There will be 12 combinations, and the matrix 12x4 would be:

{apple, black, square, dog}
{apple, black, square, cat}
{apple, black, circle, dog}
{apple, black, circle, cat}
{grape, black, square, dog}
{grape, black, square, cat}
{grape, black, circle, dog}
{grape, black, circle, cat}
{lemon, black, square, dog}
{lemon, black, square, cat}
{lemon, black, circle, dog}
{lemon, black, circle, cat}

The result in the matrix are sorted, in that way we have the elements of set W in column 1, elements of set X in column 2, and so on.

So, when I called the result value of row 7 column 3 (R7C3) is 'circle'.

I have try to simplified this to make the calculation easier. I turn the sets of element and the result into number as index. So the set of elements would be:

W = {1, 2, 3}
X = {1}
Y = {1, 2}
Z = {1, 2}

This might seems confusing because all set have the same element value. But since it is placed ordered, each set will bet put in one column. And the matrix 12x4 result is:

{1, 1, 1, 1}
{1, 1, 1, 2}
{1, 1, 2, 1}
{1, 1, 2, 2}
{2, 1, 1, 1}
{2, 1, 1, 2}
{2, 1, 2, 1}
{2, 1, 2, 2}
{3, 1, 1, 1}
{3, 1, 1, 2}
{3, 1, 2, 1}
{3, 1, 2, 2}

Therefore when I want to find the value RmCn, I can map the value as index to the set of elements.

For example, value in R7C3 is 1. Column (n) = 3 means the set number 3 (set Y). Take the value (1) as index of the element in set Y, which is 'circle'.

There are specific questions regarding my question, but it is only answer the possibility .

Is there any equation that can find the value of combination in RmCn?

$\endgroup$

1 Answer 1

1
$\begingroup$

Notice that the rightmost element cycles directly through all its values, in your case going $1,2,1,2,1,2,1,2$. If the set $D$ had $d$ elements, then the final column would be equal to $1,2,\dots, d, 1,2,\dots, d\dots$.

So, the value of the last column and row $i$ is simply the $k$-th element of the (ordered) set $D$, where $k$ is the remainder of $i$ divided by the size of set $D$.


The one column before that behaves differently. Here, the first element of $C$ is repeated as many times as there are elements of $D$, then the second element is repeated, then the third, and then you get a cycle.

Therefore, the value of the $i$-th row can be obtained by counting how many repetitions of length $d$ you can fit into rows $1,2,\dots, i$, in other words, you look at $x=\frac{i}{d}$ and round the result up to see in which repetition you are on.

Then, again, just look at the remainder of $x$ when divided by $c$, the number of elements in set $C$.


For the column before that behaves similarly, except that the elements now repeat $cd$ times and not just $d$ times. In the first column, the elements repead $bcd$ times (just multiply the sizes of all sets to the right of the current column).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.