Number of 3 element subsets of ${1,2,...,n}$ with a certain property. Given the set $\{1,2,\dots,n\}$, I want to count the number of three-element subsets $\{x,y,z\}$ such that $|x-y|=1$ or $|x-z| = 1$ or $|y-z|=1$. I'm not familiar with how to deal with the "inclusive or" in a counting problem. 
As someone pointed out, we can equivalently count the number of triples $\{x,y,z\}$ such that $|x-y|>1$ and $|x-z|>1$ and $|y-z|>1$. 
 A: You need a pair of successive integers and an arbitrary one. And then subtract those three integers that have two successive ones. That likes Inc-Exc Principle. You have $n-1$ choices for successive ones and then have $n-2$ choices for that arbitrary one. For subtracting, we know there successive integers have two successive ones that there is $n-2$ ones. So the answer is:
$$(n-1)(n-2) - (n-2) = (n-2)^2$$
A: Consider the complement: count the number of three-element subsets $\{x,y,z\}$ $1\leq x<y<z\leq n$ such that $s:=y-x\geq 2$ and $t:=z-y\geq 2$
where $x+s+t\leq n$. It follows that counting the complement is the same as finding the number of non-negative integer solutions of the equation
$$A+B+C+D=n-5$$
where $A:=x-1$, $B=s-2$, $C=t-2$. By stars-and-bars, this number is $\binom{n-5+3}{3}=\binom{n-2}{3}$. Hence the answer is
$$\binom{n}{3}-\binom{n-2}{3}=(n-2)^2.$$
A: I think your first have to built a two elements subset of two consecutive integers. There is $n - 1$ ways to do. Then, you chose the last element between the $n - 2$ elements that remain. Finally there is $(n - 1)(n - 2)$ such subsets. 
