# I need a formula for how many ways I can choose $k$ balls (two balls each time from the same box) from $n$ boxes?

We have $n$ (can take any value $1,2,3,...$) boxes each has the same number of distinct marbles, say $b$ marbles, so the total number of marbles $S=n*b$. We can choose marbles from boxes with the following conditions:

1- The marbles in each box are divided into equal subsets each with size $k$ (can take any value, , the sample case when $k=1$), so each box contains $\frac {b}{k}$ subsets, and there is a total of $\frac {n*b}{k}$ subsets in all available boxes. note that k is integer only $(1\le k\le b)$

2- Marbles only can be chosen as subsets not individuals.

3- we can choose any number of subsets $m$, each has a size $k$.

We want a general formula for the number of combinations of choosing any number of the marbles subsets from the available boxes. As example for the sample case: subset size k=1, then the solution will be $S=\binom {n*b}{m*k}$

I want a formula for the other cases such as: $3$ boxes $(n=3)$ each has $9$ distinct marbles $(b=9)$, the subset size $k=3$, so the number of available subsets in each box will be $\frac {9}{3}=3$ subsets (total $9$ subsets in the $3$ boxes), what the number of possible ways to choose $4$ subsets each with size $k=3 (m=4)$?

• Before answering the genral question, I need to understand why you think the answer in the example is $12$. The actual number is $6\cdot 6$, not $6+6$. – André Nicolas Aug 23 '13 at 17:54
• From your example, the balls appear to be distinct. Does each box contain the same number of balls? – André Nicolas Aug 23 '13 at 17:59
• Could you please edit your question to answer the above questions, and also explain what happens for larger values of k, e.g. k=4? (E.g. is choosing {a,b} then {c,d} the same as choosing {c,d} then {a,b}; is it the same as choosing {a,c} then {b,d}?) I'm worried that your question will attract answers that take a "best guess" at what the question means. – Douglas S. Stones Aug 23 '13 at 18:20
• For every one of the $6$ choices you have from the first box, you have $6$ choices for what you take from the second box, so we need to take the product, not the sum. You have not answered the quesition of whether each box has the same number of balls. If they do, the answer is quite simple. If they don't, it is significantly messier. – André Nicolas Aug 23 '13 at 19:37
• Is this the question?: Let $\{X_i\}_{i=1}^n$ be a partition of a set $X$ into $n$ parts of size $b$. How many $k$-subsets $S \subseteq X$ are there such that $|S \cap X_i|$ is even for all $i \in \{1,2,\ldots,n\}$? – Douglas S. Stones Aug 23 '13 at 21:01

Since we are choosing $2$ balls from each box, the number $k$ must be even. It is convenient to let $k=2m$.

It has been indicated in a comment that each box has the same number of balls, say $b$ balls.

There are $\binom{n}{m}$ ways to select the boxes we will take two balls each from.

For each way of selecting the boxes, we can choose $2$ balls from any of the selected boxes in $\binom{b}{2}$ ways. It follows that the total number of choices is $$\binom{n}{m}\binom{b}{2}^m.$$

Remark: Suppose we are choosing $2$ balls each from particular boxes, say boxes A, B, and C. There are $\binom{b}{2}$ ways to choose $2$ balls from box A. For every choice of balls from box A, there are $\binom{b}{2}$ ways to select $2$ balls from box B. Thus the number of ways to choose from A and B is $\binom{b}{2}\binom{b}{2}$ (we multioply). For every way of choosing $2$ balls from A and $2$ from B, there are $\binom{b}{2}$ ways to choose $2$ balls from C. So the number of ways to select $2$ balls from each of A, B, and C is $\binom{b}{2}^3$.

Added: The above formula counts the number of ways to choose a total of $k$ balls, where for any one of the $n$ boxes, exactly $2$ balls are chosen from that box, or $0$ balls are chosen from that box.

There are many other questions one could ask, with roughly similar wording. In order to make it possible to give a precise answer to such similar-sounding questions, the choosing rule has to be stated exactly.

• But the OP's comment indicates it's possible to repeatedly select from the same box (in the "(12,34)" and "(ab,cd)" examples). – Douglas S. Stones Aug 23 '13 at 20:51
• We have $n$ boxes. Each has $b$ marbles. All marbles are distinct. We want to choose $k=2m$ marbles. From any box, we can either take exactly $2$ marbles or exactly $0$. In all your examples, we had $m=n$, meaning we took $2$ marbles from every box, but the formula I gave is more general. By the way, the system objects to long strings of comments. I will delete most of mine, suggest you do the same. But you can continue to ask questions! – André Nicolas Aug 24 '13 at 17:52
• With $6$ marbles from two boxes, the situation is different, and not covered by the formula. The formula deals only with situations where we are choosing $2$ (or $0$) from each box. If you still want an even number from each box, then we choose all from the first box, and $2$ from the other or the other way around. Then the answer is $\binom{4}{2}+\binom{4}{2}=12$. – André Nicolas Aug 24 '13 at 21:36
• This is what I'm trying to say, (But my English is not good). I want a general formula for any even number of marbles available in both boxes (0, 2, 4, 6, or 8) for the example I give. – user91515 Aug 24 '13 at 22:19
• For very general problems of this type, generating functions might be useful. If you want an answer, the problem should at first be broad enough for the answer to be useful to you, and narrow enough to have a chance of a solution. I urge that if you ask a question, it be absolutely clear. – André Nicolas Aug 24 '13 at 23:48