Color changing chameleons
Logic Problem #4
Problem
The long quarantine has allowed for nature to flourish in some places and the animal population has increased at a lot of places. A remote jungle has three types of chameleons, red ones, green ones, and blue ones. If you are not familiar with chameleons, these reptiles can change their body colors at will according to their environment.
For the purpose of our puzzle, these reptiles show some interesting behavior. Each time two chameleons with different colors meet, they change their color to the third color. For example, if a green chameleon meets a red one, they both change their color to blue! Is it ever possible for all chameleons to become the same color? Why or why not? Would it depend on the initial starting population of the different color species?
Start with 13 red, 15 green, and 17 blue chameleons and try to get an answer.

Solution
If you’ve been following us, you would have observed that a common trick in solving such puzzles is trying to solve a very simple version of the puzzle first. Let’s think if there are only one chameleon of each color, then we can easily convert all of them to a single color. What about if we have 1 red, 2 blue, 3 green! Try it out and you’ll find that it is not possible after some iterations.
To make the numbers easier to follow, let us encode the population in a compact format: (r, g, b), where r,g,b are the number of different colors.
The total number of chameleons is: (13+15+17)=45, and hence we want to get the final state as: t=(0,0,45) or any of its other two permutations. What is our initial vector? It is: a=(13,15,17).
Now that these two have been decided, we’d like to find the type of operations that we can do! When two chameleons of different colors meet, they change to the third color. The population of the initial two colors reduce by one each and rises by two for the third color. Following the same format as above, this operation can be written as op=(-1,-1,+2) or permuted to two other variants.
Simplifying a bit, it looks like we have the following equation (where n is the number of times the operation will be performed):
a + n * op = tIf we expand and write it, then:
(13,15,17) + n*(-1,-1,+2) = (0,0,45)Something looks odd! n should be an integer for this to have a valid answer. These tuples that are written can be each permuted to two other settings! Since initially we said that op,t are all any one arbitrary permutation chosen out of the three others. (In simpler words, you can set the target to 45 red or blue chameleons, or the operation can be switched too).
Since we are talking about groups of 3 all the time, we make use of the mod operator now. This gives us the remainder when two numbers are divided! It has some very interesting properties which are used in number theory too. Eg: 5 mod 3 = 2, which can be written as 5 => 2 (mod 2). For negative numbers, it can be understood as the number to be subtracted to make it a multiple of 3.
Eg: -1 mod 3 = 2
Taking (mod 3) of the above equation, we get:
(1, 0, 2) + n*(2, 2, 2) =? (0,0,0) (mod 3)We need integer answers for n!
Let’s try n=0, the left-hand side of the equation would be (3,2,4) which is (0,2,1) mod 3. Similarly, if we try for n=1 & n=2, we find no matches for the right-hand side! We don’t need to check for n greater than 2, since the answers will start repeating under the modular condition. Hence, there is no method by which we can ever reach a population of a single color, under this starting condition.
There are a few other methods to solve this puzzle as well! If you found some others, please drop a comment and we can discuss it. (Hint: try to see if some relation between r,g,b stays invariant under modular operations during the process.)
Hope you liked this newsletter! Please drop a like if you did and share it with your friends! We are excited to share that we have moved our archives to Medium too!


I wondered what can be the pre final stage cases for this problem, so I assumed an initial number of x,y, and z for each type of chameleon and assumed that everyone converts to the z type. So in my version of a pre final stage (assuming pairing of x-y chameleons until one of the types is exhausted), we would be left with (x-y) or (y-x) number of single coloured chameleons depending upon what's positive. Then, by taking examples for 1,2,3 to be the number at pre final stage, one can figure out the pattern that the pre final stage number should be divisible by 3.
Well I used one method, correct me if i am wrong, taking 3 chameleons case, and we have to convert them to red, so converting them to Red until one color has 0 chameleons left, as asked in above problem (28,0,2). Then the other color left i.e. blue color, will be reduced by 3 (taking 1 of red and 1 of blue changing them to green, then taking 1 blue and 1 green to convert them to Red, doing this twice), doing this it will give (27,2,1), then (29,1,0) and we can continue no further, so the remaining color should be a multiple of 3(or mod%3=0) to be able to convert all chameleons to Red or any other color.