Picking balls from urns. 
We have 2 urns, 5 red balls and 5 green balls. We will split the 10 balls in the 2 urns in any way we like (provided that each urn has exactly 5 balls) and then will choose one urn at random, of which we will pick one ball.
  If the ball is red, we will be asked to draw a second one from the other urn. If the first ball is green, we will keep it out of the urn and draw a second one from the same urn. We will win 100,000 rupees if we pick 2 balls of the same color. What is the optimum way to split the balls in the urns? (obviously the urns are identical, they are not transparent and we can’t cheat! Also, once we split the balls, the urns are taken away and brought back to us, so that we don't know which is which.)

Obviously we can't put 5 red in one urn and 5 green in the other, because if we pick the urn with the red balls, we will never pick 2 of the same color. So both jars must contain both colors but I can't figure out the optimum combination. I was told it is something about a Bayes theorem, but I am not familiar with this (although I looked it up in wiki). 
Any help? Many thanks!
 A: There will be an urn in which the number $r$ of red balls will satisfy
$r\in\left\{ 0,1,2\right\} $. 
To be found is an answer to the question: "for which of the options $r=0,1,2$ will $P(S)$ be maximal?"
Let $E$ denote the event that this
urn will be chosen at random and let $S$ denote the event that two
balls are chosen that have the same color. 
If $r=0$ then $S=E$ hence $P\left(S\right)=P\left(E\right)=\frac{1}{2}$.
If $r\in\left\{ 1,2\right\} $ then $$P\left(S\right)=P\left(E\right)P\left(S\mid E\right)+P\left(E^{\complement}\right)P\left(S\mid E^{\complement}\right)=\frac{1}{2}\left[P\left(S\mid E\right)+P\left(S\mid E^{\complement}\right)\right]$$
Here $$P\left(S\mid E\right)=\frac{r}{5}\frac{5-r}{5}+\frac{5-r}{5}\frac{4-r}{4}$$
and $$P\left(S\mid E^{\complement}\right)=\frac{5-r}{5}\frac{r}{5}+\frac{r}{5}\frac{r-1}{4}$$
(do you see why?).
Now substitute $r=1,2$ and draw conclusions.
A: Let $a$ be the number of red balls in the first urn. Then we have $5-a$ green balls in the first urn and $a$ green balls in the second urn (means that $5-a$ red balls in the second urn). Then, we are trying to maximize the probability of getting $2$ balls with the same color. Here, let $R$ be the event that we pick $2$ red balls and $G$ be the event that we pick $2$ green balls. Then,
$$P(R) = \underbrace{\frac{1}{2}\cdot \frac{a}{5}\cdot \frac{5-a}{5}}_{\text{if we pick first urn first}}+\underbrace{\frac{1}{2}\cdot \frac{5-a}{5}\cdot \frac{a}{5}}_{\text{if we pick second urn first}} = \frac{(5-a)a}{25}$$
and
$$P(G) = \underbrace{\frac{1}{2}\cdot\frac{5-a}{5}\cdot \frac{4-a}{4}}_{\text{if we pick first urn first}}+\underbrace{\frac{1}{2}\cdot \frac{a}{5}\cdot \frac{a-1}{4}}_{\text{if we pick second urn first}} = \frac{a^2-5a+10}{20}$$
Then, $P(R \cup G) = P(R)+P(G)$ is the probability we are trying to maximize.
$$P(R)+P(G) = \frac{5a-a^2}{25}+\frac{a^2-5a+10}{20} = \frac{a^2-5a+50}{100}$$
Here, we need to find maximum value of the function $f(a) = a^2-5a+50$ in the interval $a \in [0,5]$ and $a \in \mathbb{N}$. Here, you can either try it for $a = 0,1,2$ or you can sketch the graph of this parabola on $[0,5]$ and see that it gets its maximum value at $a = 0$ and $a = 5$ with $50\%$.
A: If you put the 5 red balls in one urn and the 5 greens in the other, you will win if you are presented the urn with the green balls first and loose if you are presented the urn with the red balls first. So you have a $50\%$ chance to win. One can do a similar computation for the other two options, ie 4 and 1 or 3 and 2 of each color in each urn. Can you compute the probability to win for these other distributions of the balls?
