Chameleons Go Monochrome
Chameleons changing color puzzle is a medium quant interview question on Brain Teasers.
This brain teaser describes an island with three types of creatures whose colors change according to a simple interaction rule when individuals of different colors meet. The puzzle asks whether it is possible, by repeatedly applying this rule in any sequence, to end up with a configuration where every creature has the same color. It is a classic state-transformation question, common in puzzle interviews and quantitative brainteaser rounds, where the candidate must reason about what end states are reachable rather than try to simulate every possible series of moves.
Solving it leans on the idea of invariants and modular arithmetic on the counts of each type. The interviewer is looking for whether the candidate identifies a suitable quantity that stays constant under the allowed operation, and uses it to classify which configurations are attainable. Strong answers explain why brute-force search is unnecessary, articulate the invariant precisely, and give a rigorous argument excluding or allowing a monochrome state, instead of relying on ad hoc experimentation or guesswork.
What it tests
Many problems involving transformations among groups or states are governed by invariants: quantities or properties that remain unchanged under the allowed operations. In this class of problems, the key is to track not the absolute counts, but how the operations affect relationships between those counts, such as their differences or their residues modulo some number. The reason invariants are so powerful is that, if the desired end state would require the invariant to change, then that state is unreachable, regardless of the sequence of moves. Here, the operation (two chameleons of different colors both changing to the third color) preserves certain modular relationships among the counts. This is because each operation redistributes chameleons in a way that cycles the counts but does not alter their sum or their residues modulo 3, so the system is trapped in a subset of possible states.
Practise this question with written feedback, or hear it in a spoken mock interview.
Get started free