Answer to The Professor's Balls
Let (R,G,Y) be current state of the balls' colours expressed as a vector, where R = the number of red balls, G the number of green balls and Y the number of yellow balls.
Here’s the trick
Therefore, if we want to know if we can get from an initial vector to an end vector, all we have to do is apply mod three to that end vector. It its in that list of three then we’ll be able to get to it. If its not, then it’s impossible.