I have a larger problem where the core could be simplified with the following analogy:
In a lottery game, there are five balls numbered from 1-5 . We call the numbers 1, 2,3 winning numbers. A lottery ticket contains 3 to 5 digits. A winning ticket must contain all three the winning numbers. How many winning tickets are possible ?
My attempts:
- Step 1: find the count of winning tickets with 3 numbers only: 3P3= 6
- Step 2: Find the count of winning tickets with 4 numbers only: 4P3 * 2 = 24*2=48 (permutation of a sample of 3 out of 4 objects times 2 which is the non winning numbers)
- Step 3: Find the count of winning tickets with 5 numbers only: 5!/2! * 2P2 = 120( winning tickets Assuming the two non-winning digits out of the 5 numbers are non-distinctive times permutation of a sample of 2 out of 2 objects which is the non winning numbers)
- Step 4: Sum all result in step 1, 2 and 3 = 6+48+120= 174
Is my attempt correct? is there a compact formula without calculating the value iteratively step by step for example, my actual problem has 100 balls out of which 30 are winning numbers?
As clarified in the comments all numbers in a ticket are different which makes the problem rather trivial. Your attempt is correct.
In general case the number of winning tickets is $$ \sum_{i=m}^n \binom{n-m}{i-m}i! $$ where $n$ is the number of balls, $m$ is the number of winning balls, $\binom{n-m}{i-m}$ and $i!$ stay for the number of ways to choose $i-m$ non-winning balls and to order the balls in a ticket containing $i$ numbers, respectively.