An island has 13 red chameleons, 15 green and 17 blue. When two of different colours meet, both turn into the third colour, and when two of the same colour meet nothing happens.
Can the island ever be all one colour?
Write an island as its three counts, red · green · blue, so the film starts at 13 · 15 · 17. A meeting takes one off two of the counts and adds two to the third. The total, 45, never changes.
This is the film's proof. A meeting changes the counts by , and . Counted in threes, taking one away and adding two are the same step, because . So a meeting moves all three remainders along by the same amount, and the gaps between them never change.
13, 15 and 17 leave remainders 1, 0, 2, all different. The differences , and are , and , and each of those is in threes. An island of one colour has two counts at zero, so one of its differences is . A difference that starts at in threes stays at , so that never happens.
Give each colour a number, red , green , blue , and add up every chameleon's number:
When an and a meet, both become the third colour . Since , the sum changes by
which is a multiple of 3. So , counted in threes, never changes. The film's island has , which leaves 1.
An island that is all red has , all green has and all blue has . All three are multiples of 3, because 45 is, and 49 is not. Done.
This route sees something the first one hides: the total matters. The three one-colour islands have , and , where is the number of chameleons. When is a multiple of 3 those leave the same remainder, so an island can reach all three or none of them. When it is not, they leave three different remainders, and exactly one is allowed.
The film says that failing is not a proof, and it is right: any number of failed attempts proves nothing. Failing everywhere is a different matter. From 13 · 15 · 17 a search that follows every meeting from every island it finds turns up exactly 360 islands, and none of them is one colour. That settles this island, by checking.
It also shows more. There are 1,081 ways to split 45 chameleons into three colours, and sorts them into three classes of 361, 360, 360. The 360 islands the film's island can reach are exactly the 360 with leaving 1. So the invariant does not just block the one-colour islands. It is the whole map: every island it allows, the chameleons can actually reach.
The film counts the first four meetings of its first attempt in threes. The remainders change every time, but they stay all different, and stays where it was:
| Meeting | Island | In threes | S in threes |
|---|---|---|---|
| start | 13 · 15 · 17 | 1, 0, 2 | 1 |
| red meets green | 12 · 14 · 19 | 0, 2, 1 | 1 |
| red meets blue | 11 · 16 · 18 | 2, 1, 0 | 1 |
| red meets blue | 10 · 18 · 17 | 1, 0, 2 | 1 |
| red meets green | 9 · 17 · 19 | 0, 2, 1 | 1 |
So "the pattern never changes" means the gaps between the remainders, not the remainders themselves. They turn round like a wheel: 1, 0, 2, then 0, 2, 1, then 2, 1, 0.
The first attempt keeps pairing the reds off, and after 22 meetings it reaches 0 · 44 · 1: one chameleon away from an all-green island. The only meeting left is green with blue, and that makes 2 · 43 · 0. The second attempt stops at 0 · 2 · 43.
That first attempt got as close as anyone can. The most chameleons of one colour the island can ever hold is 44, and only three islands manage it:
| Island | In threes | Reachable from 13 · 15 · 17? |
|---|---|---|
| 0 · 44 · 1 | 0, 2, 1 | yes, in 16 meetings |
| 1 · 0 · 44 | 1, 0, 2 | yes, in 15 meetings |
| 44 · 1 · 0 | 2, 1, 0 | yes, in 17 meetings |
| 1 · 44 · 0 | 1, 2, 0 | no |
| 0 · 1 · 44 | 0, 1, 2 | no |
| 44 · 0 · 1 | 2, 0, 1 | no |
The second attempt could have done one better. Instead of 43 blue and 2 green, it could have reached 1 · 0 · 44, in 15 meetings.
Here is every island of 45 at once. A point's position is its mix of colours: the corners are the one-colour islands, and the closer a point is to a corner, the more of that colour it has. A meeting is a short step towards the corner of the colour that gained two. Every run in the film stays on dots of its own colour.
The film's control moves one chameleon: 13 · 16 · 16 leaves remainders 1, 1, 1, all the same, which puts it among the gold dots with all three corners. The film takes it to all green in 16 meetings, and that is the fewest possible: every meeting removes at most one blue chameleon, and there are 16 to remove.
Pick an island, or set your own counts, and make the meetings. The lab counts in threes as you go and says which colours are still possible. The "fastest way" buttons play a shortest route, and say "never" when there is none.
| Island | In threes | All red | All green | All blue |
|---|---|---|---|---|
| 13 · 15 · 17 | 1, 0, 2 | never | never | never |
| 13 · 16 · 16 | 1, 1, 1 | 16 | 16 | 16 |
| 13 · 15 · 18 | 1, 0, 0 | 18 | never | never |
The claim has a second half: if the other two counts agree in threes, the island really can end all colour , in exactly as many meetings as the larger of those two counts.
Call the other two colours and . Meet an with a until one of them runs out. Each of those meetings takes one off both, so their difference stays the same, and it was a multiple of 3. What is left is chameleons of one colour, say , and some of colour . Now three meetings move three of them across:
Count it up: loses 3, gains 2 and loses 2, and loses 1 and gains 4. Repeat times. The number of meetings is .
No route can be quicker. All chameleons of one colour and all of the other have to go, and a meeting removes at most one of each, so it takes at least meetings.
| Island | In threes | All red | All green | All blue |
|---|---|---|---|---|
| 13 · 15 · 17 | 1, 0, 2 | never | never | never |
| 13 · 16 · 16 | 1, 1, 1 | 16 | 16 | 16 |
| 13 · 15 · 18 | 1, 0, 0 | 18 | never | never |
Adding one blue chameleon to the film's island makes 13 · 15 · 18, 46 in all. Now green and blue agree in threes, so the island can end all red, in 18 meetings, and no other colour.
Change the total. With a multiple of 3, an island can end every colour or none, as the film's two islands do. With any other total, a mixed island can always end exactly one colour. The table in "Checking it" counts every case.
Let only one of the pair change. Suppose that when two of different colours meet, just one of them turns into the third colour. Now changes by , which is not a multiple of 3, and the invariant is gone: from 13 · 15 · 17 the island can reach all 1,078 mixed islands of 45. It still never ends one colour, for a simpler reason. Look at the last meeting. The chameleon that did not change still has its own colour, and the one that changed now has the third, which is a different colour. So that meeting always leaves two colours behind. The trick is gone, but a different argument takes its place.
The three kinds of meeting add one of , or to the counts. Every entry of each is in threes, so any combination of them has all three entries equal in threes, and adds up to zero. Conversely, the difference of the first two is , so steps of 3 between any two colours are combinations too, and together with one meeting they make every such vector. So the meetings, as arithmetic, can make exactly the changes that keep . Among all the ways of moving chameleons from one colour to another, that is one change in three, which is why the islands fall into three classes.
Arithmetic is not the whole question, because a meeting needs both colours to be there. Even so, for every mixed island of up to 45 chameleons the script checks that it can reach every island in its class and nothing else. The route above is a proof of the part that matters for the puzzle, the one-colour islands.
What if nobody steers? Suppose that every so often two chameleons of different colours meet, every such pair equally likely. The film's island never finishes, since nothing in its class is one colour. The control island can finish, and in 16 meetings, but chance is not trying to finish. Left to random meetings it takes about meetings on average, and it ends red, green or blue a third of the time each, to six decimal places.
The reason is that chance pushes towards balance. A colour with many chameleons turns up in most meetings and loses one every time, and it only gains when the two other colours meet. So random meetings drag the counts towards a third each, and finishing means climbing all the way out against that pull. By the time the island finishes, it has long forgotten where it started, which is why the three colours come out equal. Starting from a third of each, the wait grows by a factor of about eight for every three more chameleons:
| Chameleons | Meetings before one colour, on average | Growth per three more chameleons |
|---|---|---|
| 6 | 26 | — |
| 9 | 270 | ×10.4 |
| 12 | 2,302 | ×8.5 |
| 15 | 18,727 | ×8.1 |
| 18 | 148,960 | ×8.0 |
| 21 | ×7.8 | |
| 24 | ×7.8 | |
| 27 | ×7.7 | |
| 30 | ×7.7 | |
| 36 | ×7.6 | |
| 45 | ×7.5 |
None of this is left to the proofs. scripts/chameleons.mjs asserts every number on this page, and the page is built from what it writes.
The film. It reads island.json, the file the film plays, and re-derives all of it with the rules in site/lib/chameleons-core.mjs: every meeting in both attempts and in the control is legal, the attempts end where the narration says, the rebound is green meeting blue, and the control's 16 meetings are the fewest possible.
Every meeting. On every island of up to 60 chameleons, all 107,970 possible meetings move the three remainders by the same step and leave alone.
Every mixed island of up to 45. That is 17,160 islands. For each one the script finds everything it can reach, checks that it is exactly the island's class, checks that it can end colour exactly when the rule says so, and checks that the fewest meetings found by searching equals the larger of the other two counts. The route described above is played out every one of the 17,100 times it applies, and arrives in that many meetings. With a total that is not a multiple of 3, every mixed island can end exactly one colour:
| Total | Mixed | One | Any | None |
|---|---|---|---|---|
| 2 | 3 | 3 | 0 | 0 |
| 3 | 7 | 0 | 1 | 6 |
| 4 | 12 | 12 | 0 | 0 |
| 5 | 18 | 18 | 0 | 0 |
| 6 | 25 | 0 | 7 | 18 |
| 7 | 33 | 33 | 0 | 0 |
| 8 | 42 | 42 | 0 | 0 |
| 9 | 52 | 0 | 16 | 36 |
| 10 | 63 | 63 | 0 | 0 |
| 11 | 75 | 75 | 0 | 0 |
| 12 | 88 | 0 | 28 | 60 |
| 30 | 493 | 0 | 163 | 330 |
| 45 | 1078 | 0 | 358 | 720 |
The variant. With only one of the pair changing, no meeting from any of the 39,530 mixed islands of up to 60 chameleons lands on one colour.
Random meetings. The chance of each ending and the expected number of meetings are solved exactly, as a Markov chain on the 358 mixed islands of the control's class. The method is checked against ordinary elimination on small islands, and against 20,000 simulated runs on islands small enough to finish.
The lab. The lab runs the functions in site/lib/chameleons-core.mjs, the same text the script imports. On 4,000 random islands the pasted copy gives the same answers as the module.
All red, in 18 meetings, and no other colour. Green and blue leave 0 and 0 in threes, so they agree, and the larger of them is 18. Red and blue leave 1 and 0, red and green 1 and 0, so all green and all blue are impossible. With 46 chameleons, not a multiple of 3, exactly one colour was always going to be possible.
Yes, at 1 · 0 · 44, which the island reaches in 15 meetings. But not at 0 · 1 · 44: its remainders are 0, 1, 2, and the island's are always 1, 0, 2 moved along, so 1, 0, 2 or 0, 2, 1 or 2, 1, 0. In terms of , 1 · 0 · 44 has , which leaves 1 like the start, and 0 · 1 · 44 has , which leaves 2.
All 16 blue chameleons have to go, and a meeting turns at most one blue chameleon into something else (two blues meeting changes nothing). So it takes at least 16 meetings. The film's run takes exactly 16.