4 ms·
For completeness: The number of possible sets that include 4 numbers from the range [0..15] is (16+4-1) choose 4, or 3876. Let's assume that our set is (a, b,
by utopcell 9y ago
For completeness: The number of possible sets that include 4 numbers from the range [0..15] is (16+4-1) choose 4, or 3876.
Let's assume that our set is (a, b, c, d). It is ordered, therefore a <= b <= c <= d. For example, a valid set is (2, 4, 4, 10).
Consider all possible numbers that may be in our set, laid out in order.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
For each element in the set, we mark its position in this order by placing a marker to the left of the corresponding number.
For our example, we first mark element 2:
0 1 m 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Then 4:
0 1 m 2 3 m 4 5 6 7 8 9 10 11 12 13 14 15
Then, 4 again:
0 1 m 2 3 m m 4 5 6 7 8 9 10 11 12 13 14 15
And finally, 10:
0 1 m 2 3 m m 4 5 6 7 8 9 m 10 11 12 13 14 15
Now, out of these 16+4 places, only 19 of them could be a valid placement for a marker, as a marker should always be placed to the left of a number (or said differently, "15" will always be in the end.)
Therefore, there are 19 choose 4 ways to pick the locations of the markers.
- shaklee3 9y agoThanks. That was really helpful.