## Task B-3.4.

Four friends have decided to spend the weekend in a small family hotel that has five rooms, each decorated in a different style and color. They are the only guests in the hotel. They have left it to the hotel owner to assign them to rooms, but with the condition that no more than two friends are in one room. In how many ways can the owner arrange them in the rooms?
## Solution.

Consider the following cases:

$1^{\circ}$ If each friend is in her own room. Then the total number of possible arrangements is 5.4.3.2 $=$ 120.

$2^{\circ}$ If only two friends are together in one room, and the other two are each in separate rooms. We can choose the two friends who will be together in a room in $\frac{4 \cdot 3}{2}=6$ ways (we divide by 2 because, for example, the pair $AB$ and $BA$ are the same arrangement). For each of these choices, we can choose 3 rooms in $5 \cdot 4 \cdot 3=60$ ways (the first room in 5 ways, the second in 4 ways, and the third in 3 ways).

Thus, the total number of arrangements in this case is $6 \cdot 60=360$.

$3^{\circ}$ If two friends are together in one room and the other two are together in another room.

It is sufficient to determine the number of ways one of the friends can choose who she will be with in the room, as this also determines the remaining pair, and it does not matter which pair is first and which is second. Thus, one friend can choose who she will be with in 3 ways, so there are 3 ways to choose two pairs of friends.

(Or: We can choose the first pair of friends who will be together in $\frac{4 \cdot 3}{2}=6$ ways. The remaining pair is determined by this. Since it does not matter which pair is first and which is second, we divide the number 6 by 2, so there are a total of 3 ways to choose two pairs.)

For each of these choices, we can choose 2 rooms in $5 \cdot 4=20$ ways.

Thus, the total number of arrangements in this case is $3 \cdot 20=60$.

The final number of all possible arrangements is obtained by summing the results of the previous cases and is $120+360+60=540$.