Geonomics Interview Question: You have 17 red and 17 blue b... | Glassdoor.co.uk

Interview Question

Software Engineer Interview

You have 17 red and 17 blue balls, and you remove 2 at a

  time. If the two are the same colour, add in one extra blue ball. If they are different colours, add in an extra red ball. What colour is the final ball removed?
Answer

Interview Answer

13 Answers

0

To answer this, assume that you always perform the same action each time (e.g remove 2 red, remove 2 blue, remove R and B) and see what you end up with. The answer is you will always end up with 1 red 1 blue in the pot, so you remove these and replace with a red. So the final ball removed is always red.

Interview Candidate on 23 Jul 2014
12

The real point is that there will always be an odd number of red balls. We start with an odd number and there are only 3 operations:
Remove 2 reds - add a blue - keeps red odd
Remove two blues - add a blue - keeps red odd
Remove one of each - add a red - keeps red odd.

Then whenever you get down to one red you can't get rid of it, since you will be always removing one red and one blue, then adding back a red.

Anonymous on 18 Mar 2015
0

Blue

Anonymous on 15 Apr 2015
0

Green ... I am useless at this type of thing ...

Anonymous on 15 Apr 2015
3

The answers above are quite correct in saying that the final ball in the pot is red, since there must always be an odd number of red balls.

However, the setup clearly states that we remove *two* balls at a time. So when we're down to one ball left in the pot, the game must be over. The "final ball removed" must therefore have been one of the final two. So if we can prove that the last pair were either both red, or both blue, then we can know what colour the final ball removed was. But if it's possible that the final pair were a red and a blue, then the answer to the question is "we cannot know".

It *is* possible that the final pair were a red and a blue, since it's possible to demonstrate at least one sequence of draws which takes you from 17 red + 17 blue to 1 red + 1 blue, then drawing those final two and replacing them with that "final red ball" which you never actually remove.

So the answer is that we cannot know.

David Woodhouse on 15 Apr 2015
0

I agree with all answers above, which demonstrates the ambiguity in the question. As has been stated you will always be left with a single Red ball as the last in the pot but I would agree with David that the removal process requires 2 balls to be extracted on each pass hence the final state will leave a single red ball.

As to the question of last "removed", well we need to be even more pedantic. When there are 2 balls left they will be 1R + 1B (Proof: always have odd number of Red). To get to the "final" state mentioned above it suggests that the Blue is the last colour no longer represented in the pot after the last successful removal step. Again agreeing with David (& being ultra pedantic) the question says you "remove two at a time" which could mean you remove them replace the red one which means either Red or Blue is last "removed" but in either order (ie we don't know)

Unfortunately this means that there are 3 possible answers for a question with only 2 colours of ball which can only draw us to the final conclusion......don't let HR set questions for Software Engineering candidates!

Paul on 18 Apr 2015
0

Grey. I'm color blind......lol

Geoff on 25 Apr 2015
0

All answers above are incorrect. There are four possible draws, blue and blue, blue and red, red and red, red and blue. Two of these entail adding a blue, the other two, adding a red. As we start with an equal number of each colour, the probability of each will remain equal. So, we do not know what colour the final ball will be.

ughaibu on 4 Jul 2015
0

It has been a while since I did that sort of thing at school but by looking at it all the starting positions begin with an even amount of blue balls and an odd number of red balls. Even numbers will divide by themselves or by two, but odd numbers will always have a 1 left over when divide by two so once each colour has gone through the sequence of cancelling each other out only the last of the odd numbered balls will remain. Each starting position results in the red balls being odd and the blue balls being even so the end result will always be the odd numbered red balls. The answer is red.

RR=B RESULTING IN 15 RED BALLS(odd) and 18(even) BALLS (There are of course only 17 balls of each colour which results in a negative value of -1 blue ball which must be carried over until a blue ball can be taken away. If you are sometimes getting a blue ball as an end result then you are probably neglecting to apply this at some point in the process).

BB=B RESULTING IN 17 RED BALLS(odd) and 16 BLUE BALLS(even)

RB=R RESULTING IN 17 RED BALLS(odd) and 18 BLUE BALLS(even) (Again the negative value of minus one must be carried over to the next blue ball)

Michael Fisher on 2 Sep 2015
1

there is no answer because ultimately you end up with

either
RRB or BBR or RRR or BBB
At which point

case: RRB
  take RR
  put B
  remaining BB
  take BB
  put B
  remaining B
OR
  take RB
  put R
  remaining RR
  take RR
  put B
  remaining B

case: BBR
  take BB
  put B
  remaining RB
  take RB
  put R
  remaining R
OR
  take RB
  put R
  remaining RB
  take RB
  put R
  remaining R

if you work out the other cases in the same manner, they end in blue or red

anonymous on 25 Nov 2015
0

To all the genius out here there is no answer to it. Both the ball having the same probability.

Every time you are taking 2 balls & returning 1.
So you need to make total 34 draws( (34-1)+1).
Now consider the situation where you have drawn 32 times & only 3 balls are left (2 draws remaining).

In that scenario, there can be only 4 combinations (RRR, RRB, RBB, BBB)

RRR -> R
RRB -> R or B
RBB -> B or R
BBB -> B

So, if the last 3 balls are red then only there is 100% chance that the final balls will be red (16.66% probability)

If you still can't understand then try it at home by taking 2 different colour paper; tear it off into 17 pieces & draw it randomly...........you will realise it.
If you are always getting 3 reds in the last 2 draws then let me know & I will scrap my Cambridge degree.

Best of luck to all the genius out here 😘

Dev on 15 Oct 2017
0

Every time you are taking 2 balls & returning 1.
So you need to make total 33 draws(34-1).

Now consider the situation where you have drawn 31 times & only 3 balls are left (2 draws remaining).

In that scenario, there can be only 4 combinations (RRR, RRB, RBB, BBB)

RRR -> R
RRB -> R or B
RBB -> B or R
BBB -> B

So, if the last 3 balls are red then only there is 100% chance that the final balls will be red (16.66% probability) vice versa for blue as well.

If you still can't understand then try it at home by taking 2 different colour paper; tear it off into 17 pieces & draw it randomly........... you will realise it.

If you are always getting 3 reds or 3 blues in the last 2 draws then let me know & I will scrap my Cambridge degree & will work with you as a slave.

Best of luck to all the genius out here 😘

Dev on 15 Oct 2017
0

Seems like the best answer would be that there isn't a final ball removed, since 2 balls were removed together and those had to be one blue and one red. Therefore, one ball is remaining and cannot be removed but that ball is red.

Anonymous on 18 Oct 2018

Add Answers or Comments

To comment on this, Sign In or Sign Up.