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 ?

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.
