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):
So, where m=1 there is only one unordered combination no matter how big N is. But what is the equation?