# Puzzle #4: Red and Blue Balls in a Bag | Amazon

**You have 20 Blue balls and 10 Red balls in a bag. You put your hand in the bag and take off two 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. What will be the color of the last ball left in the bag?**

**Notes:**

Assume you have a big supply of Blue and Red balls for this purpose. When you take the two balls out, you don’t put them back in, so the number of balls in the bag keeps decreasing.

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

**Puzzle Solution:**

There can be 3 possible cases taking off 2 balls from bag.

a) If we take off 1 Red and 1 Blue, in fact we will take off 1 Blue

b) If we take off 2 Red, in fact we will take off 2 Red (and add 1 Blue)

c) If we take off 2 Blue, in fact we will take off 1 Blue

So In case of (a) or (c), we are only take off one Blue ball. Also, we always take off Red balls two by two.

1) 20 Blue, 10 Red balls

If there are 10 (even) number of Red balls, we can not have one single Red ball left in the bag, so the last ball will be Blue.

2) 20 Blue, 11 Red balls

Now as the no. of Red balls is odd, there will be one single Red ball in the bag with other Blue balls, and whenever we remove 1 Red and 1 Blue ball, we end up taking off only the Blue ball. So the Red ball will be the last ball in the bag.

#RedandBlueBallsinaBag #InterviewPuzzle #Puzzle #AmazonInterviewPuzzle