# Combinations and possible selective outcomes

We have a pool of numbers 1 thru 22. We then draw four numbers. Once a number is drawn, it is out of the pool. We repeat the drawing until we have gone thru all the 7,315 combinations.

I used MATLAB function combntns(set,subset)

Now the hard part: Assume that you want to only keep combinations, where no more than 2 out of 4 numbers are the same.

What is the formula to find out how many valid combinations there are?

Here are the first few valid combinations: $(1,2,3,4):(1,2,5,6):(1,2,7,8):(1,2,9,10):(1,2,11,12):(1,2,13,14)...$

Thank you for the help - DJ

-
Other than the examples u gave of valid combinations, once we have picked your examples would (3,4,5,6);(3,4,7,8)... ;(3,4,21,22) be counted as valid picks ? – Hardy Feb 14 '12 at 18:49
unless they appear in the 1,2,x,x thru 2,20,21,22 they would be valid – David Jones Feb 14 '12 at 19:07
2,20,21,22 does n't appear in the sequence of 1,2,x,x – Hardy Feb 14 '12 at 19:34
I just got all the answers (263) thanks to a programmer. Now if we can derive the formula to apply it to other sets. [[1, 2, 3, 4], [1, 2, 5, 6], [1, 2, 7, 8], [1, 2, 9, 10], [1, 2, 11, 12], [1, 2, 13, 14], [1, 2, 15, 16], [1, 2, 17, 18], [1, 2, 19, 20], – David Jones Feb 14 '12 at 19:43
There does n't seem to be any pattern in your sequence or is there ? like consider your example [1, 8, 12, 13], [1, 8, 19, 22], [1, 8, 20, 21], [2, 3, 5, 8] – Hardy Feb 15 '12 at 21:34