In the Navy we had bunk beds with a locker and lock both built in. You could gain access with a combination lock on the side that you could reprogram the code for. The lock was nothing more than several push buttons. Ive wondered for a long time now how many possible combinations there were. I believe the lock had $n=4$ buttons, but I would like to generalize to all $n\in\Bbb N$.
The system is easy enough to understand. Here are the rules:
- there are $n$ push buttons
- each button can be pressed no more than once, and clearly you needn't push any button at all.
- the locker combination can comprise of any number of distinct pressings.
- order of pressing is relevant, so its a permutation problem
- any grouping of buttons can be pressed simultaneously (wherein concurrently pressed buttons have no order).
So, for example, if there are $n=3$ buttons and we are pressing all three buttons then $(1)(2)(3)$ is a viable combination, which is distinct from $(2)(1)(3)$ and from $(3)(2)(1)$, et. cetera, totaling 6 possible permutations when pressed separately. These are three button, three pressing combinations.
But those combinations are also distinct from three button, two pressing combinations such as $(1)(23)$ and $(12)(3)$ and three button, one pressing combinations like $(123)$. These were an additional three when (some) pressings are done concurrently, but since the order of the pressings are relevant then $(3)(12)$ and $(23)(1)$ are two more. Note that $(12)=(21)$ since concurrently pressed buttons have no order. But $(1)(23)\ne (23)(1)$ since the non-concurrently pressed groups $(1)$ and $(23)$ are ordered with respect to one another.
Naturally, one can press but two of the three, one of the three, or none of the three, for a multitude of additional possible combinations.
Id like to solve this problem, but in particular for the $n=4$ case but also in the general case.
This is a problem Ive been trying to solve for a decade.
For three buttons $1,2,3$ the combinations are $(), (1), (2), (3), (12), (13), (23), (123), (1)(2), (2)(1), (1)(3), (3)(1), (2)(3), (3)(2), (1)(23), (23)(1), (13)(2), (2)(13), (12)(3), (3)(12), (1)(2)(3), (1)(3)(2), (2)(1)(3), (2)(3)(1), (3)(1)(2), (3)(2)(1)$
26 combinations unless I missed some.
I shouldnt have to specify that there is no explicit limit on the number of pressings a combination can comprise, but you are implicitly restricted by the number of buttons and the fact that each can be pressed no more than once.
There are $\dbinom{n}{k}$ ways to choose k objects from a set of $n$ buttons, and there are $S(k,j)$ (Stirling numbers of the second kind) ways to partition these $k$ labeled objects into $j$ different (unlabeled) sets, and $j!$ ways to order these sets. In total, that makes
$$\sum_{k=0}^{n}\left[\dbinom{n}{k} \sum_{j=0}^{k} S(k,j) \: j!\right]$$
ways. Letting $a_{k}$ denoting the $k$th ordered Bell Number, there are
$$\sum_{k=0}^n\dbinom{n}{k} a_{k}$$
different combinations.