(Generalization) Possibilities of picking k nonconsecutive from n consecutive numbers. The original task asked how many possibilities there are to pick 6 out of 45 numbers, where no two of those 6 differ by 1.
The solution of an even further simplified problem (3 out of 8) would look lke this:  

Write zeroes for the numbers which are not picked and ones for those which are. Since you take three, 5 zeroes remain. Then you have 6 places to pick from so the ones don't touch. Thus $\binom{~6~}{~3~}$.
 0 0 0 0 0
^ ^ ^ ^ ^ ^


But what if I wanted them to differ by at least 3? (Originally, they had to differ by at least 2, $\{1, 3, 5\}$ was valid, now only combinations like $\{1,4,8\}$ are.)
I started by rearranging the possible locations for the (representative) ones:
  0 0 0 0 0
 ^   ^   ^ 

But then I kinda have the same problem with the locations of the numbers as I had with the numbers themselves in the original, because this
 0 0 0 0 0
^     ^   ^

would also be valid. Now I have 6 locations from which some are valid, but I don't know how many (in general), and that is something I didn't have before (I think?). 
So how can I proceed from here? (To ultimately obtain a formula for picking k numbers out of n consecutive integers, where each 2 out of those k are at least d apart.)
 A: Assume without loss of generality that the $45$ numbers are $1,2,3,\dots,45$.
For any such choice of numbers $\{x_1,x_2,x_3,x_4,x_5,x_6\}$ where $1\leq x_1<x_2<\dots<x_6\leq 45$ where $|x_i-x_j|\geq 2$ for all $i\neq j$ (i.e. six numbers, none of which are consecutive), there is a bijection to the related question of finding $y_1,y_2,\dots,y_6$ using the bijection $y_{i} =\begin{cases} x_1&\text{if}~i=1\\ x_{i}-x_{i-1}&\text{if}~i\in\{2,3,4,5,6\}\end{cases}$ subject to $y_1+y_2+\dots+y_6 \leq 45$ and $y_1\geq 1, y_i\geq 2$ for each other $i$.
Let us also create an additional variable $y_7 = 45-x_6$.
We have then reduced the problem to the following:

How many non-negative integer solutions exist to the system:
$\begin{cases} y_1+y_2+\dots+y_7=45\\
y_1\geq 1\\
y_2\geq 2\\
y_3\geq 2\\
y_4\geq 2\\
y_5\geq 2\\
y_6\geq 2\\
y_7\geq 0\end{cases}$

With one more simplification, let us look at the question where $z_i=\begin{cases}y_i-1&\text{if}~i=1\\y_i&\text{if}~i=7\\ y_i-2&\text{if}~i\in \{2,3,\dots,6\}\end{cases}$
This simplifies the question to

How many non-negative integer solutions exist to the system:
$\begin{cases}z_1+z_2+\dots+z_7 = 34\\
z_1\geq 0\\
z_2\geq 0\\
\vdots\\
z_7\geq 0\end{cases}$

This is a known problem type and the solution can be seen via stars-and-bars.

$\binom{34+7-1}{7-1}=\binom{40}{6}$


This solution could easily be generalized to the case of picking $k$ numbers out of $n$ such that each must be at distance $d$ away from one another.

 For the generalized problem, we arrive at $\begin{cases}y_1+y_2+\dots+y_{k+1} = n\\ y_1\geq 1\\ y_2\geq d\\ y_3\geq d\\ \vdots\\ y_{k+1}\geq 0\end{cases}$ giving $\binom{n+k+1-1-(k-1)d-1}{k} = \binom{n+k+d-dk-1}{k}$

