How many sets of three integers between 1 and 20 are possible if no two consecutive integers are to be in a set? Total number of sets is $$\begin{pmatrix}20\\3\end{pmatrix}$$
I tried to classify  sets having two consecutive integers in them into three parts


*

*having either 1 or 20

*having both 1 and 20

*not having both 1 and 20


Trying the first : took permutation first and divided it by 3! to get combination 
(probably went there wrong)$$ \frac{2 *18 *16}{3!}  $$
what should I do ?
 A: You started out right, there are $\binom{20}{3}$ sets.  Now we have to subtract the number of sets with two consecutive numbers.  There are $19$ pairs of consecutive numbers and for each of these, we have $18$ choices for the third number, so that makes $19\cdot18$.  However, if a set has $3$ consecutive numbers, we've subtracted it twice, and so we have to add these $18$ sets back in.  Altogether, we have $$\binom{20}{3}-19\cdot18+18$$ 
You might want to look at https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle
A: The number of ways we can select three numbers from $\{1, 2, 3, \ldots, 20\}$ so that no two of them are consecutive is the number of ways we can arrange $17$ blue and $3$ green balls so that no two of the green balls are consecutive.
Line up $17$ blue balls in a row.  This creates $18$ spaces, $16$ between successive blue balls and two at the ends of the row.  

To ensure that no two of the green balls are consecutive, we choose three of these $18$ spaces in which to insert a green ball, which can be done in 
$$\binom{18}{3}$$
ways.  For instance, if we choose the first, seventh, and eleventh spaces, we obtain the arrangement

Once the green balls have been placed, we number the balls from left to right. The numbers on the green balls are the desired subset of three numbers from $\{1, 2, 3, \ldots, 20\}$ since no two of those numbers are consecutive.  In the example illustrated above, those nonconsecutive numbers are $1, 8, 13$.
