Fog Creek Software
Discussion Board

Last ball -- just a small comment

The given solution looks a bit overloaded to me. The simpler one(of course, it is basically the same) would be:
blue * blue = blue,
red * red=blue,
red * blue=red,
These are exactly the rules to multiply positive and negative integers.
So let's replace the blue balls by cards with +1, and the red ones -- by cards with -1. Taking two out and placing one in we actually multiply all our numbers pair by pair, again and again till the end. The result's sign(the color of the last ball) finally will be - or + depending on whether the number of -1 cards(red balls) is odd or even.
Best regards,

Dmitri Krylov
Tuesday, August 12, 2003

*  Recent Topics

*  Fog Creek Home