I am trying to write Javascript code to calculate the number of possible ways in which a user can make selections given containers $A, B, C, D, E$, each with $10$ items numbered $1$ through $10$ (each container has the same items). I need help with the formula for making this calculation.
A user must select from at least $2$ containers ($s=2$), but can select from all of them. The order of selection is important. For example, choices a user makes could be:
- $B_2, C_5$ ($s=2$)
- $C_5, B_2$ ($s=2$)
- $A_9, B_1, C_3$ ($s=3$)
- $C_3, B_1, A_9$ ($s=3$)
My understanding is that the standard way to calculate the number of variants is $I^C$ (number of items ($I$) raised to number of containers ($C$)), which in this case would be $10^5$. I am pretty sure this is incorrect because it doesn't account for the order of selection.
How can I calculate the number of possible user selections for different values of "s," "I" and "c"?
Update: To make this clearer, assume that once a user picks an item from a container it is closed and cannot be opened. A user can select one item and only one item from each container. They MUST select from 2 containers, but can select from more as they wish. The challenge here may not be obvious and is what I am struggling with – because the ORDER of selection matters, there are more possibilities than most well-known formulas will indicate.
Best Answer
The number of permutations will be a sum that starts with $s$ factors and goes up to $5$ factors (the number of containers). In other words:
In Javascript, the code would look like this:
This code prints: