Rearranging the tiles in a Rubik's cube net Consider the following image:

Given that there are 54 tiles in this net--9 of each of the 6 colors--we can say that there are $\frac{54!}{9!^6}$ unique ways to arrange the tiles in this net. Now, consider the 6 3x3 squares, each of which have 9 of the same colored tiles. What is the probability that our rearrangement will contain two same-color tiles that are touching (meaning that they share a side)? We do not need to worry about tiles in one 3x3 face touching adjacent tiles that below to another 3x3 face, but simply tiles touching within their respective faces. Thank you in advance.
 A: With a little help from our electronic friends, this is actually not as difficult to compute  as it might seem. The computation can be organized using generating functions. As is often the case, they serve here merely as a bookkeeping device, and the computation could be formulated without them – I just find it easier to think of convolutions of counts of complicated configurations as products of generating functions.
Associate the monomial $\prod_kx_k^{n_k}$ with a configuration with $n_k$ tiles of colour $k$ . Then a polynomial that is a linear combination with integer coefficients of such monomials represents counts of different configurations. Let $P(x_1,\ldots,x_6)$ denote the polynomial that represents all admissible configurations of one $3\times3$ square, i.e. it counts the ways in which the square can be coloured such that no two adjacent tiles have the same colour. Then the count of admissible configurations of the entire net of $54$ tiles is the coefficient of $x_1^9\cdots x_6^9$ in $P(x_1,\ldots,x_6)^6$.
Here’s Java code that performs this computation. By making use of the high symmetry of the problem and dropping terms with exponents above $9$, it never needs to retain more than $227$ terms at a time, so the computation doesn’t take long. The result is that there are $779371552365370814877373251723600$ admissible configurations. Thus the probability that no two adjacent tiles have the same colour is
$$
\frac{9!^6\cdot779371552365370814877373251723600}{54!}=\frac{240814346917986285649911399}{31237598017434328973915592130000}\approx7.71\cdot10^{-6}\;.
$$
To check this for plausibility, note that there are $72$ pairs of adjacent tiles and each has a probability of $\frac{9-1}{54-1}=\frac8{53}$ of being monochromatic. If we pretend that these events are all independent, we can estimate the probability of none of them occurring by $\left(\frac{45}{53}\right)^{72}\approx7.65\cdot10^{-6}$, in good agreement with the computation. That the exact probability is slightly higher is plausible, since one might expect positive correlation among the monochromatic pairs – both because a monochromatic $2\times2$ square produces $4$ monochromatic pairs with a probability of roughly $6^{-3}$ instead of $6^{-4}$, and because lots of other pairs being monochromatic makes the distribution of the remaining colours slightly more unbalanced.
Here’s Java code that performs a simulation to check the result. In a sample of one billion configurations, it found 7728 without monochromatic pairs, for an estimated probability of $7.73\cdot10^{-6}$, again in good agreement with the computation.
To answer your question, which asks for the complementary probability of at least one pair of adjacent tiles having the same colour: The probability for this is about $0.99999229$.
