# A question about combinatorics

You are sorting assigning 6 people, A, B, C, D, E and F, into 3 different hotel rooms. How many ways can they be sorted such that A is in the same room with C, and B is not in the same room with D? (Some hotel rooms may be empty.)

7C5 * 2! * 5! – 6C4 * 2! * 2! *4!

=5040-1440

=3600

#### Solutions Collecting From Web of "A question about combinatorics"

Another solution.

Since A and C are in same room we have to assign 5 to 3 rooms.
It can be done in $3^5$ ways.This also contains cases when B and D are in same room.
The count of ways is $3^4$ because we have to assign 4 to 3 room.

Subtracting we get $3^5 – 3^4 = 162$

There are $3$ ways to assign B to a room, and then $2$ ways to assign D. That leaves the pair AC and the individuals E and F to be assigned; each of these three ‘people’ can be assigned to any of the three rooms, so they can be assigned in $3^3$ ways. The total number of allowable assignments is therefore $$3\cdot2\cdot3^3=2\cdot3^4=162\;.$$

Note that your answer can’t possibly be right: if there were no restrictions, each of the $6$ people could be assigned to any of the $3$ rooms; that’s a $3$-way choice made $6$ times, so it can be done in $3^6=729$ ways. Thus, your answer is way bigger than the number of possible assignments when there are no restrictions at all. The number of assignments satisfying the restrictions on A, B, C, and D must be smaller than $729$.