The only combinations that work have a total number of chameleons that is a multiple of 3. It's also true that when a given set that works is taken from this scientist's collection, the numbers in the remaining set also work, for the other terrarium. So the combinations listed below include, on the left, totals of 18 or fewer, paired with, on the right, the remaining sets of counts of the chameleons that are left. As it doesn't matter which color is which, the numbers are shown in ascending order. As a result, the complementary set on the right will always be the reverse order of whatever colors are represented on the left, as the complements would be expected to decrease in order.
So for example, to read the case of 6 in one terrarium and 30 in the other, an example of the first such line could be considered 0 blue chameleons, 1 red and 5 green, and in the other terrarium, 12 blue, 11 red and 7 green.
0 1 2 10 11 12
0 1 5 7 11 12
0 2 4 8 10 12
1 2 3 9 10 11
0 1 8 4 11 12
0 2 7 5 10 12
0 4 5 7 8 12
1 2 6 6 10 11
1 3 5 7 9 11
2 3 4 8 9 10
0 1 11 1 11 12
0 2 10 2 10 12
0 4 8 4 8 12
0 5 7 5 7 12
1 2 9 3 10 11
1 3 8 4 9 11
1 5 6 6 7 11
2 3 7 5 9 10
2 4 6 6 8 10
3 4 5 7 8 9
0 4 11 1 8 12
0 5 10 2 7 12
0 7 8 4 5 12
1 2 12 0 10 11
1 3 11 1 9 11
1 5 9 3 7 11
1 6 8 4 6 11
2 3 10 2 9 10
2 4 9 3 8 10
2 6 7 5 6 10
3 4 8 4 8 9
3 5 7 5 7 9
4 5 6 6 7 8
0 7 11 1 5 12
0 8 10 2 4 12
1 5 12 0 7 11
1 6 11 1 6 11
1 8 9 3 4 11
2 4 12 0 8 10
2 6 10 2 6 10
2 7 9 3 5 10
3 4 11 1 8 9
3 5 10 2 7 9
3 7 8 4 5 9
4 5 9 3 7 8
4 6 8 4 6 8
5 6 7 5 6 7
The program was run with the various n = 3, 6, etc.
DECLARE SUB trace (a!, b!, c!)
CLEAR , , 25000
n = 18
DIM SHARED used(n, n, n)
CLS
used(n, 0, 0) = 1
used(0, n, 0) = 1
used(0, 0, n) = 1
trace n, 0, 0
trace 0, n, 0
trace 0, 0, n
FOR a = 0 TO n / 3
FOR b = a TO (n - a) / 2
c = n - a - b
IF used(a, b, c) = 0 THEN
IF a <= 12 AND b <= 12 AND c <= 12 THEN
PRINT a; b; c, , 12 - c; 12 - b; 12 - a
END IF
END IF
NEXT
NEXT
SUB trace (a, b, c)
FOR which = 1 TO 3
SELECT CASE which
CASE 1
FOR i = 2 TO a STEP 2
pa = a - i: pb = b + i / 2: pc = c + i / 2
IF used(pa, pb, pc) = 0 THEN
used(pa, pb, pc) = 1
trace pa, pb, pc
END IF
NEXT
CASE 2
FOR i = 2 TO b STEP 2
pb = b - i: pa = a + i / 2: pc = c + i / 2
IF used(pa, pb, pc) = 0 THEN
used(pa, pb, pc) = 1
trace pa, pb, pc
END IF
NEXT
CASE 3
FOR i = 2 TO c STEP 2
pc = c - i: pb = b + i / 2: pa = a + i / 2
IF used(pa, pb, pc) = 0 THEN
used(pa, pb, pc) = 1
trace pa, pb, pc
END IF
NEXT
END SELECT
NEXT
END SUB
Based on a puzzle by Pradeep Mutalik, presented at nytimes.com/tierneylab.
|