Find the number of ways to choose $7$ integers Generating Funciton Find the number of ways to choose $7$ integers from $\{1, 2,.., x\}$ where the gap between the smallest integer and the 2nd smallest one is at least $5$, and the gap between the 2nd  and 3rd smallest one is at least $8$. 
I know that the first part is $\binom{x-2}{7}$ ways but I am not sure how to further solve this given the condition of 2nd and 3rd smallest.
 A: It should be clear that $x$ is at least 18 for this question to make sense.
Write your 7 integers down in order. There are six differences between them: $d_1 = x_2 - x_1, \ldots, d_6 = x_7 - x_6$. They are at least $d_1 = 5$, $d_2 = 8$ and $d_3 = \ldots = d_6 = 1$. There is also a hidden difference $d_7$ between $1$ and $x_1$, which is at least $0$. 
So for example $(x_1, \dots, x_7) = (1, 8, 18, 25, 26, 28, 30)$ corresponds with
$$ (d_1, \ldots, d_6, d_7) = (7, 10, 7, 1, 2, 2, 0).$$
These seven numbers uniquely determine your sequence. Represent them by seven jars of marbles, where the first jar contains at least 5 marbles, the second at least 8, and 3 up to 6 contain at least one marble.
Every time you raise $x$ by one, you're allowing yourself an extra degree of freedom; a marble, which can be put in one of the seven jars, or which you can keep in your hand, leaving the sequence unchanged. If you put a marble in a jar, raise the corresponding difference by one. So for $x = 19$, you get eight combinations. 
The question now is, if $x = 18 + d$, in how many ways we can distribute $d$ marbles over 7 jars and your hand, i.e. 8 jars, order-independent; You are probably familiar with solving this sort of problem.
