1

Guest 1 does not wish to use rooms 1,2,3. Guest 2 does not wish to use room 4. Guest 3 does not wish to use room 5. Guest 4 does not wish to use room 6. Guest 5 does not wish to use room 7. Each room can accommodate only one guest.

I've tried simplifying the problem by considering 6 rooms with guest 1 not wanting rooms 1 and 2. I've tried applying the concept of derangements here to get the answer $256$. If $f(x)$ represents the number of derangements of $x $ objects. $$ f(6)-f(4)=256 $$ But I'm not able to adapt this to 7 rooms.

1 Answers1

3

This answer uses rook polynomials, for more details on the theory see my answer here or you will find plenty of information on the Web. I would highly recommend learning about rook polynomials as they provide a powerful tool for quite a variety of problems, especially permutations with restricted positions and matching problems.

The problem is equivalent to placing $5$ non-attacking rooks on the following chessboard.

$$\begin{array}{cc} &\text{rooms}\\ \text{guests}& \begin{array}{c|c|c|c|c|c|c|c|} & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ \hline 1 & \bbox[silver,10px]{\phantom{H}} & \bbox[silver,10px]{\phantom{H}} & \bbox[silver,10px]{\phantom{H}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} \\ \hline 2 & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \bbox[silver,10px]{\phantom{H}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} \\ \hline 3 & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \bbox[silver,10px]{\phantom{H}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} \\ \hline 4 & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \bbox[silver,10px]{\phantom{H}} & \Large\phantom{\unicode{x265c}} \\ \hline 5 & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \bbox[silver,10px]{\phantom{H}} \\ \hline\end{array} \end{array}$$

for example, a valid configuration is:

$$\begin{array}{cc} &\text{rooms}\\ \text{guests}& \begin{array}{c|c|c|c|c|c|c|c|} & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ \hline 1 & \bbox[silver,10px]{\phantom{H}} & \bbox[silver,10px]{\phantom{H}} & \bbox[silver,10px]{\phantom{H}} & \Large\unicode{x265c} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} \\ \hline 2 & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\unicode{x265c} & \bbox[silver,10px]{\phantom{H}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} \\ \hline 3 & \Large\unicode{x265c} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \bbox[silver,10px]{\phantom{H}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} \\ \hline 4 & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\unicode{x265c} & \bbox[silver,10px]{\phantom{H}} & \Large\phantom{\unicode{x265c}} \\ \hline 5 & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\phantom{\unicode{x265c}} & \Large\unicode{x265c} & \bbox[silver,10px]{\phantom{H}} \\ \hline\end{array} \end{array}$$

which is the room assignment:

$$\begin{array}{c|c|c|c|c|c} \text{guest} &1 &2 &3 &4 &5 \\ \hline\text{room} &4 &3 &1 &5 &6\\ \end{array}$$

Now you have $5$ disjunct forbidden subboards, the one in the top row made of $3$ horizontally adjacent squares which has rook polynomial

$$1+3x$$

and one in each row $2,3,4$ and $5$, each with rook polynomial

$$1+x$$

since these subboards are disjunct (no common rows or columns) we can simply multiply them to give the rook polynomial for the entire subboard

$$(1+3x)(1+x)^4 = 1+7x+18x^2+22x^3+13x^4+3x^5$$

which can then be modified to give the polynomial

$$x^7-7x^6+18x^5-22x^4+13x^3-3x^2$$

which can be used according to rook theory to give the desired count

$$\begin{align}\text{desired count}&=\frac{1}{(7-5)!}\int_{0}^{\infty}e^{-x}(x^7-7x^6+18x^5-22x^4+13x^3-3x^2)\: dx \\&= 852\end{align}$$

N. Shales
  • 3,683
  • Feeding the rook diagram into the rook solver you referenced in your other answer yielded $1704$. I think the $2!$ in your answer is not required. – Vishnu V.S Apr 04 '17 at 18:03
  • That solver is for a square chessboard, it will usee the same number of rooks as there are rows. It is why I didn't reference it here, your chessboard is a $5\times 7$ rectangle. The $2!$ is so that we get, say, for the $x^7$ term after integrating $7\cdot 6\cdot 5\cdot 4\cdot 3=\frac{7!}{2!}$. This $/2!$ comes about in each term because there are $5,4,3\ldots$ rooks being placed in $7,6,5,\ldots$ columns. – N. Shales Apr 04 '17 at 18:11
  • So the answer to the 6 guests version would be $128$ ? – Vishnu V.S Apr 04 '17 at 18:13
  • I'm trying to understand the derangement method ( in the question )... Why are we dividing by $2$ when we take derangement into account ? – Vishnu V.S Apr 04 '17 at 18:15
  • No, you are right with that, it is $256$ because the rook polynomial in that case is $(1+2x)(1+x)^4=1+6x+14x^2+16x^3+9x^4+2x^5$ which gives a modified polynomial $x^6-6x^5+14x^4-16x^3+9x^2-2x$ which gives a count $\frac{1}{(6-5)!}(6!-6\cdot 5!+14\cdot 4! - 16\cdot 3! +9\cdot 2! - 2\cdot 1!)$. The $/2!$ in your question comes from the difference in rows and columns, in the 6 room version (not guest there are $5$ of those in both cases) that difference is $6-5=1$, so obviously this has no effect when dividing by $1!$. – N. Shales Apr 04 '17 at 18:30
  • Got it. Thanks !!! – Vishnu V.S Apr 04 '17 at 18:31