Prove by induction what is the color of the last ball in the box 
A box contains $p$ red balls and $q$ yellow balls. Suppose the following procedure is repeated until a single ball remains in the box:

*

*Remove two balls from the box;

*If both have the same color, put a red ball in the box;

*Otherwise, put an yellow ball in the box.

In both cases, do not put the removed balls back in the box.
What's the color of the last ball? Prove by induction in the number of balls $p+q$.

Firstly, I thought about the base case: assuming $p+q=1$, either there is a red ball or an yellow ball. What do I do with this? I don't know even how to guess what would be the color of the last ball. Does this problem require knowledge of probability theory?
 A: Hint: from your recent comment, it seems that the question is asking you to determine the final result as a function of $p$ and $q$ (not any kind of probability). The answer is that the final result is red if $q$ is even and yellow if $q$ is odd. To see this note that the pairs $(p, q)$ transform on each step as follows:
$$
(p, q) \mapsto \left\{\begin{array}{ll}
(p-1, q) & \quad \mbox{if the selection is red-red}\\
(p-1, q) & \quad \mbox{if the selection is red-yellow}\\
(p+1, q-2) & \quad \mbox{if the selection is yellow-yellow}\\
\end{array}\right.
$$
In all three cases, if $q$ is even it stays even and if $q$ is odd it stays odd. So on the last step, when one of $p$ and $q$ is $1$ and the other is $0$, then we will have $q = 0$ if it was originally even (giving a red final result) and we will have $q = 1$ if it was originally odd (giving a yellow final result).
I leave it to you to give a more formal verification of the above argument by an induction, e.g., showing that after step $i$, $q_{i+1}$ is even iff $q_1$ is even and that $p_{i+1} + q_{i+1} = p_i + q_i - 1$ (unless $p_i + q_i = 1$, in which case the procedure terminates).
