How many combinations of 12 rolls of a die exists where each number is rolled at least once If you roll a die 12 times, how many combinations exist where all 6 sides appear at least once. Can anyone help me figure out how to solve this problem in a succinct formula.
 A: Out of the 12 times, you already have 6 times of known results: each side up appears once. So you only need to care about the remaining 6 times. The question simplifies to: If you roll a die 6 times, how many combinations do you have?
Let's think about a simpler case: If you roll a die 2 times, how many combinations do you have? Answer would be: 6 x 6 - 6. There are 6 duplicated combinations when 2 rolls produce a same side, so we need to subtract the duplicated 6.
Then let's think about another simpler case: If you roll a die 3 times, how many combinations do you have? Answer would be: 6 x 6 x 6 - 6 x 6 + 6. There are 6 duplicated combinations when 2 rolls produce a same side, and the remaining roll can produce 6 results, so we need to subtract the duplicated 6 x 6. However, we over-count duplications for 6 cases when 3 rolls produce a same side, so we add back 6.
By the same counting method, the case: If you roll a die 6 times, how many combinations do you have? Answer would be: pow(6, 6) - pow(6, 5) + pow(6, 4) - pow(6, 3) + pow(6, 2) - pow(6, 1) = 39990.
In general, for N rolls, number of different combinations = sum( pow(-1, N - j) * pow(6, j) ), j = N, N-1, ..., 1.
