Modular Boxes

So, there is a bit of a follow-up to my puzzle last time I had intended to post, but then life got all busy on me, or I am just a slacker or something, but I noticed something funny about the puzzle last time.

When I had worked out that the elements of the 9th row of Pascals triangle (getting 1,9,36,84,126,126,84,36,9,1) and I noticed that they were all multiples of 3 (except for the 1's, of course) I instantly knew that this row must need a minus sign, without having to count and realize that the odd rows get a minus sign and the even rows do not. The reason is that if this particular row did not have a minus sign, then the statement "first box + last box = top box (mod 3)" would depend on how you mapped the boxes to the numbers. If blue=0, red=1, and green=2, then red+red would be green, but if blue=2, red=1, and green=0, then red+red would be blue. Clearly it cannot be the case that the solution to the puzzle depends on how you map the boxes to the numbers, so there must be a minus sign (and -red-red comes out to red in any mapping).

So does this mean something fundamental about the numbers that appear in Pascals triangle? Did I stumble on to some new property that I hadn't seen before? I couldn't quite see what it meant, really.

Talking about it with Ben, he noted that the statement "the answer comes out independent of how you map the colours" it actually a statement about linear functions made up of rows of Pascals triangle (so for example 1,3,3,1 makes 1w+3x+3y+1z). It must be the case that shifting all the variables by a constant shifts the answer by that same constant, and multiplying all the variables by a constant multiplies the answer by that same constant (and any 1-1 mapping of {red, green, blue} to {0,1,2} can be shifted to any other mapping by adding constants or multiplying by constants).

Since the linear functions in question are, well, linear, the multiplying by a constant thing is trivial. As for adding a constant, if we shift (w,x,y,z) to (w+a,x+a,y+a,z+a) then 1w+3x+3y+1z becomes 1w+3x+3y+1z+8a, where 8 is the sum of the elements of that row of Pascals triangle, and naturally -1w-3x-3y-1z becomes -1w-3x-3y-1z-8a. Since 8 mod 3 is -1, we can see that the expression with the minus sign is the one that shifts by exactly a when you shift all of its inputs by a.

This means that a row will shift correctly under this linear transformation if it has a minus sign when the sum of the row is -1 mod 3, and no minus sign if the row sums to 1 mod 3, and where will be a problem if any row sums to 0 mod 3.

Of course, we know the sum of a row of the kth Pascals triangle is 2^k, and that is (-1)^k mod 3, so this is exactly the property we needed, the rows alternate summing to 1 and -1.

I'm not sure anybody else found that as interesting as I did, since it was mostly about stuff that went on in my own head and ended with a fact that anybody who knows about Pascals triangle already knew, but I decided it was worth a post anwyay.