Example of valid number are:
(1) 431
(2) 543
(3) 210
(4) 321
Example of not valid number are:
(1) 221
(2) 500
(3) 654
The answer is 120 but I don't know why.
My attempt:
I have to construct a string of length $n=3$ with some constraints. I split the problem into 5 small problems.
$D_1 = \{\text{all valid number staring with 1}\}$
$|D_1| = 0$
$D_2 = \{\text{all valid number staring with 2}\}$
$|D_2| = 1 \times {2\choose 2}$, because I can choose only from $\{0,1\}$
$D_3 = \{\text{all valid number staring with 3}\}$
$|D_3| = 1 \times {3\choose 2}$, because I can choose only from $\{0,1,2\}$
$D_4 = \{\text{all valid number staring with 4}\}$
$|D_4| = 1 \times {4\choose 2}$, because I can choose only from $\{0,1,2,3\}$
$D_5 = \{\text{all valid number staring with 5}\}$
$|D_5| = 1 \times {5\choose 2}$, because I can choose only from $\{0,1,2,3,4\}$
My solution: $$\sum_{i \in \{1,2,3,4,5\}}|D_i| = 35$$ I can sum directly because there is no double counting but it's wrong...
Editing from the future:
I made a mistake on the summation, the solution is 20. And from the textbook 120 were not the correct answer...
$$\sum_{i \in \{1,2,3,4,5\}}|D_i| = 20$$ I can sum directly because each set is disjoint (there is no double counting). In conclusion my long not-necessary aproach was right but (if you are reading this post) I recommend you to read all the comments below and the answers because they helped me a lot.