Given a set S of m unique numbers, n slots are to be filled using those m numbers. What are the number of ways to do it, given the following constraints:
- A particular number from those m numbers should always be present in atleast one of the slots, and that number x will be given.
- Any number can be picked any number of times, i.e., repetition is allowed in the slots.
- Two ways are different if atleast one of the slots differ.
Example:
S = {2, 4, 6}, So, m = 3. Given, n = 4 and x = 2.
Here, x = 2, so in all of the ways, 2 will be present in atleast one of the slots.
Few of the possible ways to fill the given n slots are:
[2, 2, 2, 2], [2, 2, 2, 4], [2, 2, 4, 4], [2, 2, 2, 6]
I have found a pattern to solve this using the number of times x is repeated in the slots, like in the given example it can be repeated 1, 2, 3 or 4 times, and for each number of times, we can count the number of possible permutations for other remaining numbers in S but this process is too lengthy. Is there any shorter way to do it?