If there is an $n\times n$ grid, and an infinite number of each of $k$ different colored balls, what is the expected number of the $2n(n-1)$ inner grid lines to have a ball of the same color on either side of the line, given that any color is equally likely to be picked for a cell?
For example, R|G is not a match, B|B is. Same for vertical adjacency.
I guessed at $\frac{2n(n-1)}{k}$ as the probability of a match is $\frac1k$. Is this right?
Enumerate the $2n(n-1)$ inner grid lines and, for $1 \leq i \leq 2n(n-1)$, let $A_i$ denote the event that the color of the two balls adjacent the $i$th grid line have the same color.
Then the total number of inner grid lines to have a ball of the same color on either side of the line is given by the sum of indicator functions, $$\sum_{i=1}^{2n(n-1)} \mathbf{1}_{A_i},$$ and we want to find the expected value of this: $$\mathbb{E}\left[\sum_{i=1}^{2n(n-1)} \mathbf{1}_{A_i}\right] = \sum_{i=1}^{2n(n-1)} \mathbb{E}\left[\mathbf{1}_{A_i}\right] = \sum_{i=1}^{2n(n-1)} \mathbb{P}\left[A_i\right].$$
At this point, under the assumption that every ball is equally likely to be one of $k$ colors and any two adjacent balls' colors are independent, we have $\mathbb{P}[A_i] = 1/k$ for any $i$.
Putting this into the above sum gives $$\sum_{i=1}^{2n(n-1)}\frac{1}{k} = \frac{2n(n-1)}{k}$$ as you had guessed.