2. A three-digit number is given. By rearranging its digits, all numbers that can be written with these digits are obtained. The sum of all these numbers is 1998. With which digits is the given three-digit number written? Find all solutions.
Solution. The given number can have two identical digits and the third one different, or all three of its digits can be different (all different from zero).

a) If all digits are different, let's say: $a, b, c$, then the sum of the numbers

$$
\begin{aligned}
& 100 a+10 b+c, 100 c+10 a+b, 100 b+10 c+a \\
& 100 a+10 c+b, 100 b+10 a+c, 100 c+10 b+a
\end{aligned}
$$

is equal to 1998, i.e., we get the equation

$$
222 a+222 b+222 c=1998
$$

from which

$$
a+b+c=9
$$

According to this, the given number can be written with the digits 1, 2, 6 or $1,3,5$ or $2,3,4$.

b) If the given number has only two different digits, let's say $x$ and $y$, then the sum of the numbers

$$
100 x+10 x+y, 100 x+10 y+x, 100 y+10 x+x
$$

is equal to 1998, i.e.,

$$
222 x+111 y=1998
$$

from which

$$
2 x+y=18
$$

According to this, the given number can be written with the digits 5, 5, 6 or $7,7,4$ or $8,8,2$.