34 chameleons live on an island. At the beginning, there are 7 yellow, 10 red, and 17 green ones. When two chameleons of different colors meet, they simultaneously adopt the third color. One day, Darwin arrives on the island and observes that all the chameleons are of the same color. What is this color?
We start by finding which color works. If a red chameleon and a green one meet, there are 9 reds, 9 yellows, and 16 greens. Then, when the 9 reds meet the 9 yellows, there are only greens left (34, to be precise).

Now let's show that there is no other possibility. By manipulating a bit, we see that $R - J$ (where $R$ and $J$ are the number of red and yellow chameleons, respectively) can either remain constant, increase, or decrease by 3. In all cases, the class modulo 3 does not change. Initially, $R - J = 3$ is zero modulo 3. If there were only red chameleons, we would have $R - J = 34$, which is not zero modulo 3, making it impossible. Similarly, if there were only yellow chameleons, we would have $R - J = -34$, which is also not zero modulo 3, making it impossible as well.

In the case of a game, invariants are at the core of "invariant maintenance" strategies.