## Task B-4.4.

Grandpa Ante, looking for a way to entertain his grandchildren Iva and Mato, found three cards. On the first card, one side has the number 1, and the other side has the number 4. On the second card, one side has the number 2, and the other side has the number 4. On the third card, one side has the number 3, and the other side also has the number 4. Grandpa Ante immediately knew how to keep the children occupied for a long time. He told the younger one, Mato, to arrange the three cards in a row, and the schoolboy Iva had to write down the three-digit numbers that Mato forms by arranging the cards and then calculate the sum of all the recorded numbers. Mato randomly picks a card and its side. How many different three-digit numbers can Ivo write down at most, and what is the sum of these numbers?
## Solution.

We need to count how many different three-digit numbers can be written using the digits 1, 2, 3, 4, 4, 4. Let's consider 4 cases:

1. Case. The three-digit number has only the digits $1, 2, 3$. Then Ivo can write at most 6 numbers: $123, 132, 213, 231, 312, 321$. Their sum is equal to the sum of all units + the sum of tens $\times 10 +$ the sum of hundreds $\times 100$, i.e., $12 + 120 + 1200 = 1332$.
2. Case. The three-digit number has only one digit 4. Then, along with the digit 4, it can have the digits 1, 2 or 1, 3 or 2, 3. Analogously to the first case, there are 6 different three-digit numbers with the digits $4, 1, 2$. The same number of possibilities exists if Mate chooses cards with the numbers $4, 1, 3$ or $4, 2, 3$. Thus, there are $3 \cdot 6 = 18$ possibilities in total. The sum of all such numbers is $14 + 140 + 1400 + 16 + 160 + 1600 + 18 + 180 + 1800 = 5328$.
3. Case. The three-digit number has two digits 4. Then, along with them, it can have the digit 1 or 2 or 3. There are three different three-digit numbers with the digits $1, 4, 4$, which are $144, 414, 441$. The same number of possibilities exists with the digits $2, 4, 4$ or $3, 4, 4$. Thus, there are $3 \cdot 3 = 9$ possibilities in total. The sum of all such numbers is $9 + 90 + 900 + 10 + 100 + 1000 + 11 + 110 + 1100 = 3330$.
4. Case. The three-digit number has all three digits 4. There is only one such number, 444.

The total number of three-digit numbers that Ivo can write is $6 + 18 + 9 + 1 = 34$.

Their total sum is $1332 + 5328 + 3330 + 444 = 10434$.