techInterview
Answers to technical interview questions - accepting donations for dogs

 
home
faq
reading
feedback
discuss
archive
fogcreek
bug tracking
pets in ny
petfinder



*new* techInterview bible


thank your brain
save a dog's life




 

Solved by jy

solution: last ball

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


 



home | software development | bug tracking software | archive

[general software discussion] [dogs new york city] [Software Quality]