*Welcome to techInterview, a site for technical interview questions, brain teasers, puzzles, quizzles (whatever the heck those are) and other things that make you think!*

You have 20 blue balls and 14 red balls in a bag. you put your hand in and remove 2 at a time. If they’re of the same color, you add a blue ball to the bag. If they’re of different colors, you add a red ball to the bag. (assume you have a big supply of blue & red balls for this purpose. note: when you take the two balls out, you don’t put them back in, so the number of balls in the bag keeps decreasing). What will be the color of the last ball left in the bag?

Once you tackle that, what if there are 20 blue balls and 13 red balls to start with?

### Solution

You always take off Red Balls two by two !

So if you start with 14 Red Balls, you cannot have one single Red ball at the end.

… so the last ball is blue.

But if you start with 13 Red Balls, as you take them off 2 by 2 (at one moment or the other you’ll do it !) you will arrive at a moment when you have 1 red ball in the bag. But as you can only take off Red Balls 2 by 2 (Did I already say that ?!) you’ll remove the last Blue Balls, one by one……

So the lastball will be red…

Oh, by the way, did I tell you that you take off Red Balls 2 by 2 ?! ;->

For tired people here is why you take off Red Balls 2 by 2 :

- If you take off 1 RED and 1 BLUE, in fact you will take off 1 BLUE

- If you take off 2 RED, in fact you will take off 2 RED (and add 1 BLUE)

- If you take off 2 BLUE, in fact you will take off 1 BLUE