I've spent most of the afternoon thinking about this, and hopefully the following is correct (but it may not be the quickest way to calculate). Please feel free to check and correct my terminology! If this method makes sense I'll use it on the original problem (later)
scenario B)
Let t = the total number of balls, in this case 7
Let p = the pick size, in this case 5
Let m = number of balls to match, in this case 3
Let n1 = the number of picked balls that match ONE of the desired numbers
Let n2 = the number of picked balls that match another ONE of the desired numbers
Let n3 = the number of picked balls that match the remaining desired number
n1 ≤ n2 ≤ n3
Let x = n1 + n2 + n3, x≤p
Let a = choose(p, x) ...the ways to place x among p picks
Let b = the ways to permute the "multiset" of x matched numbers
Let c = (t-m)^(p-x) ...the number of permutations of the unmatched numbers
Let d = the ways to rearrange {n1,n2,n3} (make a new multiset out of them) eg if {1,1,2} then d=3!/2!
Code:
n1 n2 n3 x a b c d a*b*c*d
1 1 1 3 10 x!/(1! 1! 1!)= 6 16 1 960
1 1 2 4 5 x!/2! =12 4 3 720
1 1 3 5 1 x!/3! =20 1 3 60
1 2 2 5 1 x!/(2! 2!) =30 1 3 90
=====
1830
C)
switch to t=8, this changes the highlighted figures
Rich (BB code):
n1 n2 n3 x a b c d a*b*c*d
1 1 1 3 10 x!/(1! 1! 1!)= 6 25 1 1500
1 1 2 4 5 x!/2! =12 5 3 900
1 1 3 5 1 x!/3! =20 1 3 60
1 2 2 5 1 x!/(2! 2!) =30 1 3 90
=====
2550