Red/blue ball challenge - Math or probability

I’m breaking out this query from a thread in MPSIMS in hopes of getting a factual answer. What’s prompting this is the large array of differing answers and logic behind the guesses there.

Here’s the question:

“You have 17 red and 17 blue balls, and you remove two at a time. If the two are the same colour, add in one extra blue ball. If they are different colours, add in one extra red ball. What colour is the final ball removed?”

Here’s a link to the thread in question:

This question is very badly stated and not clear at all.

You’re saying I “have” 34 balls and then I “remove” them. Presumably that means the balls are in some kind of container; let’s call it a bag. So there are 17 red and 17 blue in the bag, then I remove two of them (presumably with my hand). Next you’re saying that if those two are the same colour, I should “add in one extra blue ball”. Add to where? From where? Are you saying I should look into the bag, find a blue ball, and add it to my hand? Or are you saying I should I should go to the source from which I originally filled the bag (perhaps a shelf of some kind?) and take a blue ball off the shelf and put it into the bag? Seriously, I’m not following you here at all. Then you start talking about a “final” ball. Now I’m totally lost. Are you implying that this procedure should be repeated as many times as possible? That was not stated explicitly. And, supposing that I do repeat the procedure (which seems to involve three balls somehow), which one of them is the one you’re calling the “final” ball? Lastly, the question doesn’t seem to be asking about probability at all, but implying that there is only one deterministic answer. This is totally out of character for problems of this sort (red/blue balls in a bag). These puzzles almost always ask about probability, even if the answer turns out to be 100% or 0%.

I don’t see how we can even BEGIN to tackle this question unless the question is cleaned up and clarified. There’s way too many ambiguities here.

To avoid extraneous ambiguity, this should be rephrased as “what colour is the single ball that is left in the bag at the end?”

There is a neat and definitive answer that I thought I saw on SDMB, but I can’t find it to link to. So, I don’t know who to credit for this, but:

The algorithm (including replacement) always net removes zero or two red balls, never a single red ball. Therefore, starting with an odd number of red balls, there must be one red ball left at the end.

The answer is simply stated in two sentences, and there is no untoward trick, so it’s definitely worth thinking about for those who are fond of such puzzles.

Ok, here’s a precise rephrasing of the interesting problem:

You have 17 red and 17 blue balls in a bag, and a reservoir of extra balls as required. You remove two balls at a time from the bag, using any choosing procedure that you wish, random or otherwise. If the two balls removed are the same colour, you add back one blue ball. If the two balls removed are different colours, you add back one extra red ball. You keep repeating this procedure until only one ball is left in the bag. What color is it?

Ok, wow. That part was not obvious at all. I’m allowed to look in the bag while I’m CHOOSING the balls? It doesn’t have to be random? I don’t think I’ve ever heard of that in any of the dozens of red/blue-balls-in-a-bag questions I’ve ever seen. That’s very surprising.

I assume you meant “add back one blue ball from the reservoir to the bag”, even though you didn’t explicitly say that.

Yes, the solution is “robust” to any choosing algorithm. It’s unusual, but if you think about it, that must be true, since the solution is not probabilistic.


And to reiterate, there is no stupid trick. It’s a problem worth thinking about. There’s a simple solution expressed in a couple on sentences, under my spoiler above.

Looks like:

Each cycle (two balls out, one ball in) can only change the contents of the bag by -1B/0R or +1B/-2R. Either way, you will always have an odd number of red balls at the end of each cycle. So you have to end with one red ball.

nm. **Riemann **beat me to the clarification of the clarification.

So what if you start with 18 balls of each color ? Think about it.

You are vastly overthinking this problem. As with the Monty Hall problem, the statement (with a couple of reasonable assumptions) is clear: if you have m red balls and n blue balls, given the rules, the resulting states are either m-2 red balls and n+1 blue balls, or m red balls and n-1 blue balls. Since the count of red balls can only go down by increments of 2 and you’ve started with an odd number (the the quantity or balance is arbitrary as long as red is an odd number) you’ll always end up with one red left over. There is no state path in which you end up with two reds or blues alone as the penultimate state.

I generally eschew these kinds of questions when interviewing potential hires, and tend to reject offers from companies which rely on this sort of “tests” as a competency metric instead of asking realistic, applied questions which demonstrate actual experience (after three levels of interviews with Google, not once did someone actually ask me a question that was pertinent to my engineering design or analysis background, nor even explain what it was that I might be working on or who I’d be working for) but for someone interviewing for a programming type position it is actually a pretty good basic problem in state logic, although in that case I would ask for a formal proof or logic diagram. If nothing else, you can just consider the bounding cases of drawing all paired sets and all matched sets and see what the logic flow is under the assumption that a deterministic path is going to give you the same answer as any random draw at the end state.


I tend to agree. I don’t think this kind of question is useful in an oral interview. I would not see an ability to “click” on the precise answer to one particular such question quickly, under pressure, as a meaningful virtue, even if it might be somewhat correlated to certain skills. If asked at all, I think a written test of many such problems would be more informative.

I do think that Fermi estimation problems are useful in oral interview.

I think an oral answer to such a problem, under pressure, does give insight into a candidate’s general mental acuity - analysis, deduction, imagination, “common sense”. Beyond interviews, it’s also a great practical skill to be able to judge quickly whether a precise calculated answer is of the correct order of magnitude.

It may seem to you that the question is clear if you already know what the question is. But to someone like me who had only just seen the question for the first time, it was NOT obvious at all. For example, white SIFL’s phrasing of the question didn’t even specify that the procedure was to be repeated. And then to say “the final ball removed” makes no sense because you’re removing them in pairs, so how can you one of them be “final”? But if you say “Keep removing pairs until there’s just one ball left. What color is that one ball?” now it makes sense.

After reading Riemann’s post, I get it. Here’s what I figured out, without looking at anybody else’s answers.

Let R be the number of red balls. There is no way to decrease R by 1. Either you take two reds and put in a blue (so R decreases by 2), or you take two blues and put in a blue (so R stays the same), or you take one red one blue and put in a red (so R stays the same). At the beginning of the puzzle, R is an odd number. So at the end it must still be an odd number. If the last ball were blue, R would be zero (which is an even number) and that can’t happen so the last ball must be red.

For the record, I just copy and pasted it from the other thread. It wasn’t my phrasing.

Agreed, which is why I said I’d ask for a formal proof or logic diagram rather than just an answer (which has a 50% probability of being correct by chance). But that is to assess a specific skill, i.e. an understanding of state logic. I wouldn’t pose that question to a mechanical designer or a fluid dynamics analyst (although I might ask it of a chemical engineer or someone with a controls background). Fermi-type estimates may seem useful in a general sense but often require domain knowledge in order to approach a sensible answer. You can see from the linked thread that five posters attempted to answer the “How many calories in a grocery store?” question came up with answers that varied over five or more orders of magnitude. Was one more right than another? Not unambiguously, nor was one process clearly better than another. I view these kinds of generic questions as lazy attempts to largely fill up the dead space in an interview. When I interview a candidate, I pose actual situations they might have to deal with in reality, such as “If you are performing an protoqualification test on a composite honeycomb conical structure and you hear popping and signs of surface buckling, how would you proceed?” or “If your 500 draw Monte Carlo analysis shows three cases exceeding your ±3σ limits, how would you assess the risk? What if it were five or eight?” Walking me through their process on this kind of problem tells me a lot about their specific experience as it applies to the position, or what they don’t know but have the basic intelligence to intuit and are therefore educable. Asking generic scaling questions or brain teasers just tells me they’re clever at Games World. I’ve worked with enough smart people to know that being clever doesn’t mean they’ll be good at doing a job any more than someone who is an imaginative tinkerer in the kitchen would make a good line cook.

I’ve never seen that problem until this morning, and it took me about five minutes of thinking to come up with three different ways of answering the problem. The implicit statements of the problem (that balls are blindly sampled without replacement in pairs; that a ball is added back to the remaining population based upon the combination of the sample; that the “final ball” is the one left after the last pair is removed from a population of three) were readily interpreted by myself and other people in this thread in the same way. Granted, the problem statement was not explicit as it could have been and required the reader to make and state assumptions about the interpretation, but then if I’m interviewing someone for a job and they’re nitpicking my language rather than making an effort to make a reasonable assumption about the intent, I’m going to know that this is a person who is going to need continuous handholding or is going to make drama out of every misinterpretation, and pass in favor of a candidate who is going to make an effort to interpret the often ambiguous requests and problems that occur in the real world.


If one really wants a comprehensive answer, you need a couple more steps in the proof (besides the even-odd red bit):

  • Verify that there is a valid operation no matter what the selection. R-R, B-B, and R-B do indeed cover all possible cases of a 2-ball selection, but a different puzzle might have left out a case.

  • Verify that there are a finite number of steps until the end case. Again, it’s easy to see that the total number of balls decreases by 1 on each step, guaranteeing that there will be exactly 33 steps until the end. A different puzzle might not be able to make the same guarantee.

Very well put. :cool:

You seem to be implying that this isn’t really a question to see if someone can do logic puzzles, but rather it’s a meta question to see how well someone handles being asked a poorly phrased question.

obligatory XKCD reference Communicating badly and then acting smug when you’re misunderstood is not cleverness.

As I understand it, the context here (as the OP explained) is that, when this puzzle was posted in MPSIMS, the answers were chaotic and all over the place. So white SIFL posted the puzzle here in GQ hoping for a factual answer. That’s how I approached the puzzle, keeping firmly in mind the fact that the person asking it specifically stated that they wanted a clearer, more logical, answer than the ones that had been given in the other forum.

There are entire books full of puzzles that can lead you do wildly different answers depending on how you interpret the question. If you want a definitive, factual answer, the first step is to verify that this isn’t one of those puzzles.

You know what they say about assumptions… they make an ass out of u and umption. It turns out that the famous Monty Hall problem has completely different answers depending on whether you assume that the host knows what’s behind each door. This is a crucial element in determining the solution, and yet it’s almost never stated in the problem itself.

May I be diplomatic and suggest that it’s wholly context dependent.

If somebody that I know reasonably well (or of course somebody in an interview) gives me a problem, and tells me it’s interesting, I will make the most likely reasonable assumptions and spend some time thinking about it.

If some random person posts something ambiguous on the internet… yeah, I’m probably going to ask for precise clarification, in part to ascertain whether it’s a genuine reasoning or lateral thinking problem that I should spend time thinking about, or just some idiotic trick answer based on infantile wordplay.

how are “someone you know reasonably well” and “someone interviewing you” in any way comparable?

The decision is about whether to spend time on the problem, is it interesting. If I’m trying to get a job, I’m going to try to answer a question on the assumption that the person I’m talking to is not an idiot. I’m not excluding asking them for clarification of a material ambiguity, just that I wouldn’t nitpick or probe to see if they were wasting my time.