# 8.2. Condition:

A five-digit number is called a pit if the first three digits are in descending order, and the last three digits are in ascending order. For example, 73016 and 98346 are pits, while 88012 and 56821 are not pits. How many pits are there that are less than the number $22222?$
Answer: 36

## Solution.

Suitable pits must start with 2, so the next is either 1 or 0. If the second position is occupied by the digit 1, then the third digit will not be greater than the second, so the condition is only satisfied by 0. Therefore, the third position is 0. The last two places can be occupied by any two different digits from 1 to 9. There are $9 \cdot 8 / 2 = 36$ such pairs of digits, because we first choose a digit for the second-to-last place (from 1 to 9), and then from the remaining eight digits we choose the one that will go at the end (from 1 to 9, excluding the digit at the second-to-last position). Since the order of the digits matters, we divide the resulting number of ways by two, as the digits are divided into pairs of the form (a, b), (b, a). For example, the combination of digits 2 and 7 can be 27 or 72 (in exactly that order), and in each such pair, only one way fits - where the digits are in descending order.