[guided]Let $x,y,z\in X$. The triangle inequality to prove is $d(x,z)\le d(x,y)+d(y,z)$.
The discrete distance only takes the values $0$ and $1$, so the key question is whether the endpoint distance $d(x,z)$ is $0$ or $1$.
First suppose $x=z$. Then the defining formula for $d$ gives $d(x,z)=0$. From the earlier nonnegativity verification, both $d(x,y)$ and $d(y,z)$ are nonnegative [real numbers](/page/Real%20Numbers). Therefore $d(x,z)=0\le d(x,y)+d(y,z)$.
Now suppose $x\ne z$. Then the defining formula gives $d(x,z)=1$. To make the right-hand side at least $1$, we only need one of the two summands $d(x,y)$ or $d(y,z)$ to equal $1$. At least one must: if both $x=y$ and $y=z$ held, transitivity of equality would give $x=z$, contradicting the present assumption $x\ne z$. Hence either $x\ne y$ or $y\ne z$. In the first case, the definition gives $d(x,y)=1$; in the second case, it gives $d(y,z)=1$. The other summand is nonnegative, so in either case $d(x,y)+d(y,z)\ge 1$. Since $d(x,z)=1$ in the case $x\ne z$, this becomes $d(x,z)\le d(x,y)+d(y,z)$.
The two cases $x=z$ and $x\ne z$ exhaust all possibilities, so the triangle inequality holds for every triple $x,y,z\in X$.[/guided]