The bag contains marbles of three different solid colors. All but two of the marbles are red. All but two of them are green. All but two of them are blue.
The answer is
three: one red, one blue, one green.
To prove that this is the only possibility, let $R,G,B$ be the numbers of marbles of each colour in the bag. "All but two of the marbles are red" means $G+B=2$, and similarly $R+B=2$ and $R+G=2$. But each of $R,G,B$ must be a non-negative integer, so now the solution is clear.
Here's my answer taking into account the possibilities of other colors. Sorry it's a bit long-winded. Any suggestions to help shorten or clarify are appreciated.
The answer is
3, one red marble, one green marble, and one blue marble.
Let $M$ = the number of marbles in the bag. Let $R, G, B$ = the number of red, green, and blue marbles in the bag respectively. Let $X$ = the number of non-red, non-blue, and non-green marbles in the bag.
$M≥3$ because the bag contains three colors of marbles and the minimum number of marbles required to satisfy this is $3$.
$R+G+B+X=M$ because all the red, green, blue, and other-colored marbles must add up to the number of marbles in the bag.
Substitute the inequality, and we have:
All but $2$ marbles are red, all but $2$ marbles are green, and all but $2$ marbles are blue. In other words, there are $2$ non-red marbles, $2$ non-green marbles, and $2$ non-blue marbles, so we have:
If we rearrange the equations, we have:
When we plug each of these into $R+G+B+X≥3$ for $X$ and solve, all but one variable cancels out in each case and we have:
Since we know $R$, $G$, and $B$ all have to be at least $1$, then $0$ is the only value for $X$ that could satisfy:
So now we know we can safely ignore $X$ because it is $0$. That means we have:
We can rearrange the first and second equations to get:
and then plug it into the third equation to get:
Now, after plugging $R$ into the previous equations, we have:
By symmetry there must be a multiple of 3 marbles. 0 can be ruled out. 3 works. 3k+3 means there are 3k+1 red, green and blue marbles, making 9k+3 marbles in total, but 3k+3=9k+3 means k=0, our only solution.
Let N be the total number of marbles, with R, G, B the number of red, green, and blue, respectively.
The conditions literally say:
R = N - 2 G = N - 2 B = N - 2
...from which R = G = B is immediate.
If you think the problem statement only permits red, green, and blue marbles in the bag, then
N = R+G+B = 3R and you can solve trivially. If you allow other colors, then it is a quick exercise in inequalities:
R + G + B <= N 3R <= N 3R <= R + 2 2R <= 2
Yielding R=G=B=0 or R=G=B=1, assuming marble counts are non-negative integers. The former would imply a bag with only two marbles, which I think few would describe as "three different solid colors"... But vacuous truth hurts my head, so who am I to judge?
The latter yields N=3 which is the solution to the puzzle.