Number of unordered combinations of N-sized subsets of an m*N-sized set I have an array of 24 batteries in my off-grid solar power system. They are arranged in a series of 4 blocks having 6 parallel-connected batteries in each. So, in my case, N=6 and m=4.
The batteries slightly vary by state of health, which is reflected in their internal resistance. This causes each of the 4 serial blocks to have slightly different resistance, which in turn causes the blocks to get charged to unequal voltage which is not ideal (some of the 4 blocks get charged to a higher voltage than the other, although they all get the same current). Given that I can measure internal resistance of each battery individually, I am about to come up with the best possible combination where the 4 blocks have the closest resistance possible.
Now, calculating resistance for a given combination is easy and is not a question.
The question is how to get all those (unordered) combinations? How many are there, and how to iterate over all of them? (so that I could write a script that would just try them all and return the best combination)
Say if N was 2 and m was 2, the 4 batteries were labeled from A to D, there would have been only 3 unordered combinations: AB+CD, AC+BD and AD+BC.
For N=3 and m=2 we get 10 (unless I have missed some):

*

*ABC+DEF

*ABD+CEF

*ABE+CDF

*ABF+CDE

*ACD+BEF

*ACE+BDF

*ACF+BDE

*ADE+BCF

*ADF+BCE

*AEF+BCD

So, where m=1 there is only one unordered combination no matter how big N is. But what is the equation?

There are $24 \choose 6$ ways to choose the first pack, $18 \choose 6$ ways to choose the second, $12 \choose 6$ to choose the third, and $6 \choose 6$ ways to choose the last.  We have overcounted by a factor $4!$ because we could choose the same four packs in any order.  This gives
$${24 \choose 6}{18 \choose 6}{12 \choose 6}{6 \choose 6}\frac 1{4!}=\frac {24!}{6!^4\cdot 4!}\approx 9.62\cdot 10^{10}$$
Generally is is $$\frac{(mN)!}{(N!)^m\cdot m!}$$
