Problem : $13$ Apples, $15$ Bananas and $17$ Cherries are put in the magic hat. When ever a collision of two different fruits occurs, they both get converted into the third type. For example $1$ Apple and $1$ Banana can collide to form $2$ cherries. No other collision is holy. Can a sequence of such magical collisions lead all $45$ fruits to give just one type?
Solution provided : Create the invariant function $f(A,B,C) = (0A+1B+2C)mod3$, this function remains constant during a collision. But $f(13,15,17) = 1$ is not same as any of final states $f(45,0,0)=f(0,45,0)=f(0,0,45)=0$. Hence this can not be done.
Query : I understood the solution but it seems non-intuitive to me. Is there any better solution to this problem?
In fact, in any collision, each of the $3$ numbers gets decremented by $1 \pmod 3$, or equivalently, gets incremented by $2 \pmod 3$.
This gives several invariants which would work, incl. the given $(0A + 1B + 2C) \pmod 3$. This is of course equivalent to $(B-C) \pmod 3$ which is symmetric with lulu's $(A-B)\pmod 3$.
Or you can simply argue that, since the $3$ numbers did not start as equal $\pmod 3$, you cannot get to $(45,0,0) = (0,45,0) = (0,0,45) = (0,0,0) \pmod 3$.