Probability, cells, and balls I have a Problem, I am trying to build a program that solves the game Minesweeper.
and I'm trying to find the probability of a bomb or a ball in each cell.
And I got stuck in a particular situation : 
Let's say I have 5 cells in a row, I know that in the first 3 cells there is 2 balls and I know that in the last 3 cells there is 2 balls.

What is the probability of the center cell to have a ball ?
I think it is 4/5 but I am not sure.
but there is Another situation more complicated :
I know the in the first 3 cells there 1 ball in the center 3 cells there is 1 ball and in the last 3 cells there is 1 ball.

What is the probability of the 3 center cells to have a ball ?
And how you found it ?
 A: Since you are writing a computer program anyway, you can just enumerate the possibilities for where balls might be located and calculate the probability that each cell contains a ball by taking the number of configurations that satisfy your constraints that have a ball in that cell, and dividing by the total number of configurations that satisfy your constraints. You are correct that the probability that center cell in the first example contains a ball is $4/5$ under independence assumptions, because there is only one way that the center could not contain a ball (all other cells contain balls) and there are 4 ways to have the ball in the center (2 choices for where to put one ball on each side of the center). In the second situation, you either have one ball in the middle, or you have one ball on one end and one ball in the next-to-last position at the other end, so there are 3 ways and you can calculate the probability that each position contains a ball by considering these 3 cases. You will get that every position has probability 1/3 of containing a ball.
A: Situation 1
If the middle has a bomb, there is a bomb to each side of the middle thus making $4$ configurations. If the middle does not contain a bomb the remaining cells have to have bombs. This makes $1$ configuration. So indeed $\frac{4}{5}$ for the middle cell to contain a bomb. All other cells have bombs in $\frac{3}{5}$ of these. So it should be like this
$$
\begin{array}{|c|c|c|c|c|}
\hline
 & & & 2 &\\
\hline
\ \tfrac{3}{5}\ & \ \tfrac{3}{5}\ & \ \tfrac{4}{5}\ & \ \tfrac{3}{5}\ & \ \tfrac{3}{5}\ \\
\hline
& 2 & & &\\
\hline
\end{array}
$$
If we add these fractions we get $\frac{16}{5}=3.2$ which is indeed the average number of bombs in these five configurations.
Situation 2
If there is a bomb in the middle, there can be no more bombs. If there is a bomb to the left next to the middle, there must be a bomb to the very right. This configuration can be mirrored to get another one. So we have three configurations and each cell contains a ball in exactly one. So it is $\frac{1}{3}$ for all cells.
\begin{array}{|c|c|c|c|c|}
\hline
 & 1 & & 1 &\\
\hline
\ \tfrac{1}{3}\ & \ \tfrac{1}{3}\ & \ \tfrac{1}{3}\ & \ \tfrac{1}{3}\ & \ \tfrac{1}{3}\ \\
\hline
& & 1 & &\\
\hline
\end{array}
and the average of $\frac{5}{3}$ fits with the configurations.
