6. In the diagram, six squares form a $2 \times 3$ grid. The middle square in the top row is marked with an R. Each of the five remaining squares is to be marked with an $\mathrm{R}, \mathrm{S}$ or $\mathrm{T}$. In how many ways can the grid be completed so that it includes at least one pair of squares side-by-side in the same row or same column that contain the same letter?
6. In the grid, there are 5 empty cells.
Ignoring the restrictions on placement, there are 3 choices of letter that can mark each square. This means that there are $3^{5}=243$ possible grids.
To count the number of ways in which the grid can be completed so that it includes at least one pair of squares side-by-side in the same row or same column that contain the same letter, we count the number of ways in which the grid can be completed so that no pair of side-by-side squares contains the same letter, and subtract this total from 243 .
We focus on the top left and bottom middle squares. Each of these must be $\mathrm{S}$ or $\mathrm{T}$.
We consider the four possible cases.
Case 1:
\begin{tabular}{|l|l|l|}
\hline $\mathrm{S}$ & $\mathrm{R}$ & \\
\hline & $\mathrm{S}$ & \\
\hline
\end{tabular}

The bottom left square cannot be $\mathrm{S}$, but can be $\mathrm{R}$ or $\mathrm{T}$ ( 2 choices).
The top right square cannot be $\mathrm{R}$, and so can be $\mathrm{T}$ or $\mathrm{S}$.
If the top right square is $\mathrm{T}$, then the bottom right square cannot be $\mathrm{S}$ or $\mathrm{T}$ and so must be $\mathrm{R}$. If the top right square is $\mathrm{S}$, then the bottom right square can be $\mathrm{R}$ or $\mathrm{T}$ (2 choices).
This means that there are 2 possibilities for the left side of the grid and 3 for the right side of the grid. These sets of possibilities are independent and so there are $2 \times 3=6$ configurations in this case.
These are
\begin{tabular}{|c|c|c|}
\hline $\mathrm{S}$ & $\mathrm{R}$ & $\mathrm{T}$ \\
\hline $\mathrm{R}$ & $\mathrm{S}$ & $\mathrm{R}$ \\
\hline
\end{tabular}
\begin{tabular}{|c|c|c|}
\hline $\mathrm{S}$ & $\mathrm{R}$ & $\mathrm{S}$ \\
\hline $\mathrm{R}$ & $\mathrm{S}$ & $\mathrm{R}$ \\
\hline
\end{tabular},
\begin{tabular}{|c|c|c|}
\hline $\mathrm{S}$ & $\mathrm{R}$ & $\mathrm{S}$ \\
\hline $\mathrm{R}$ & $\mathrm{S}$ & $\mathrm{T}$ \\
\hline
\end{tabular}
\begin{tabular}{|c|c|c|}
\hline $\mathrm{S}$ & $\mathrm{R}$ & $\mathrm{T}$ \\
\hline $\mathrm{T}$ & $\mathrm{S}$ & $\mathrm{R}$ \\
\hline
\end{tabular},
\begin{tabular}{|c|c|c|}
\hline $\mathrm{S}$ & $\mathrm{R}$ & $\mathrm{S}$ \\
\hline $\mathrm{T}$ & $\mathrm{S}$ & $\mathrm{R}$ \\
\hline
\end{tabular},
\begin{tabular}{|c|c|c|}
\hline $\mathrm{S}$ & $\mathrm{R}$ & $\mathrm{S}$ \\
\hline $\mathrm{T}$ & $\mathrm{S}$ & $\mathrm{T}$ \\
\hline
\end{tabular} .

Case 2: \begin{tabular}{|l|l|l|} \hline $\mathrm{T}$ & $\mathrm{R}$ & \\ \hline & $\mathrm{T}$ & \\ \hline \end{tabular} changing the T's to S's and the S's to T's in the list of possibilites in Case 1.

Case 3:
\begin{tabular}{|l|l|l|}
\hline $\mathrm{S}$ & $\mathrm{R}$ & \\
\hline & $\mathrm{T}$ & \\
\hline
\end{tabular}

Here, the bottom left cell must be R.
As in Case 1, there are 3 possible ways to fill the right side.
This gives 3 configurations:
\begin{tabular}{|l|l|l|}
\hline $\mathrm{S}$ & $\mathrm{R}$ & $\mathrm{T}$ \\
\hline $\mathrm{R}$ & $\mathrm{T}$ & $\mathrm{R}$ \\
\hline
\end{tabular}
\begin{tabular}{|l|l|l|}
\hline $\mathrm{S}$ & $\mathrm{R}$ & $\mathrm{T}$ \\
\hline $\mathrm{R}$ & $\mathrm{T}$ & $\mathrm{S}$ \\
\hline
\end{tabular},
\begin{tabular}{|l|l|l|}
\hline $\mathrm{S}$ & $\mathrm{R}$ & $\mathrm{S}$ \\
\hline $\mathrm{R}$ & $\mathrm{T}$ & $\mathrm{R}$ \\
\hline
\end{tabular}.

Case 4: \begin{tabular}{|r|l|l|} \hline $\mathrm{T}$ & $\mathrm{R}$ & \\ \hline & $\mathrm{S}$ & \\ \hline \end{tabular}
As in Case 3, there are 3 configurations. These can be obtained from those in Case 3 by changing the T's to S's and the S's to T's in the list of possibilities from Case 3.
In total, there are thus $6+6+3+3=18$ configurations for which there are no two side-by-side cells that contain the same letter.
This means that there are $243-18=225$ configurations in which there are two side-by-side cells that contain the same letter.
ANSWER: 225