I hope you are familiar with this.
Basically
Each strand of 20 lights is wired like a 5x4 grid, and each bulb can be either blue, red, purple, or green. However, when you change the color of 1 bulb, the adjacent ones in the grid will cycle to the next color as well.
e.g
You change the color of the 1st light and the 2nd and 6th lights also change to red. You change it again, and the same three become purple. Cycle again makes them green, and one last time brought them back to blue. Just to make sure, you cycle through the colors of the 7th light and notice the 2nd, 6th, 8th, and 12th lights follow suit.
Now you've just drawn out some really cool random patterns! (for example, red blue green red green blue purple etc. etc.)
My question is:
Is it always possible to change the lights to match your pattern or does there exist some configurations for which it is impossible?
Answer
Short answer:
Yes, it's always possible.
Somewhat less short answer with no spoiler tags:
Your puzzle appears to be:
Given any two configurations of lights, is it always possible to reach one from the other? (Scenario 1)
This is equivalent to the following question, which is the one I will address:
Given any configuration of lights, is it always possible to reach the configuration where all lights are blue? (Scenario 2)
A proof of this equivalency is at the end of my answer.
I'll expand on the ideas presented here to show that the answer to scenario 2 is yes. I'm new to this particular stack and as such I don't know what the mathematical background of the "typical" user here is, so I'll explain in as much basic detail as I can.
For any single given light bulb starting on blue, the sequence of colors is: blue → red → purple → green → blue
Anyway, an example of a 5x4 grid with these values is as follows. (The mathematician in me is obligated to point out that I interpret "5x4 grid" as 5 rows and 4 columns, but based on your further description you clearly meant 5 columns and 4 rows, so I will proceed like that for consistency.) 00000111123123222333
Now, here's where we see why this numbering is useful. In other words, here's where we get mathy. If we change one of the lights, then that light and its two, three, or four neighbors (whichever of the top, bottom, left, and right neighbors actually exist in the grid) also get changed. And here's the important part: "Getting changed" means we add 1 to the light's numeric value, modulo 4. "Modulo 4" means if we have 3+1=4, then we replace 4 with 0 (because 4 modulo 4 is 0, i.e., the remainder is 0 when 4 is divided by 4). Here is a complete list of how a single light can change:
- If a blue light (value 0) gets changed, it becomes red (value 1, which is 0+1).
- If a red light (value 1) gets changed, it becomes purple (value 2, which is 1+1).
- If a purple light (value 2) gets changed, it becomes green (value 3, which is 2+1).
- If a green light (value 3) gets changed, it becomes blue (value 0, which is 3+1 modulo 4).
So, continuing with our example configuration above, if we were to change the light in row 3, column 4, boxed here for emphasis: 00000111123123222333
So, to summarize the main points so far:
- Blue = 0, red = 1, purple = 2, green = 3.
- Changing a light means adding 1 (modulo 4) to its numeric value and to the numeric values of its existing neighbors.
- Each light in our grid has its own special matrix Aij, where i is the row of the light and j is the column of the light.
- Changing a light in row i and column j in the configuration is represented mathematically by adding Aij (modulo 4) to the numeric representation of the configuration.
Recall the question we're addressing:
Given any configuration of lights, is it always possible to reach the configuration where all lights are blue? (Scenario 2)
Note that "all lights are blue" corresponds to the following matrix: B=[00000000000000000000]
Given any matrix with 4 rows and 5 columns where each entry is one of the numbers 0, 1, 2, or 3, is it possible to add some combination of the Aij matrices (as defined above) modulo 4, so that we end up with the matrix B (also defined above)? (Scenario 3a)
Using more sophisticated mathematical notation, we can rephrase Scenario 3a as follows:
Fix S∈Z4×54. Can we always find xij∈Z4 that satisfy the following equation, where Aij and B are as defined above? S+4∑i=15∑j=1xijAij=B
(Scenario 3b)
Note that since B has only zeros in it, then this equation is equivalent to: 4∑i=15∑j=1xijAij=−S
First, the big ∑ ("sigma") is just a shorthand way of writing a sum of a bunch of numbers.
Second, S∈Z4×54 is just a mathy (and perhaps non-standard) way of saying what we said in Scenario 3a: S is a matrix with 4 rows and 5 columns, and each entry of S is one of 0, 1, 2, or 3.
Next, what are the xij∈Z4? The notation just means each xij can only be 0, 1, 2, or 3. And what do these xij actually represent? Well, xij represents the number of times that we add Aij to our configuration. In other words, xij represents the number of times we change the light in row i and column j. Note that this is why each xij can only be one of 0, 1, 2, or 3: Because if we change a light, say, 4 times, that's the same as doing absolutely nothing, because after 4 changes it's back to its original color (mathematically, it's because 4 modulo 4 is 0). And if we change a light, say, 6 times, that's the same as changing it 4 times and then 2 more times, and since those first 4 times are the equivalent of doing nothing, then we really only changed the light twice, with those last two changes (mathematically, it's because 6 modulo 4 is 2).
So now that we've got this down to a linear algebra problem, how do we actually answer it? Luckily, we actually know what all of the Aij are. We explicitly wrote down a few of them earlier in this post. Here is one more, just as another example: A24=[00010001110001000000]
Anyway, since we explicitly know all 20 of the Aij for i=1,2,3,4 and j=1,2,3,4,5, then we can explicitly write down what the following sum is: 4∑i=15∑j=1xijAij
So, after all this, we end up with the standard linear algebra equation Ax=M,
Recall that our goal was to determine whether or not we can always find values xij that solve the equation in Scenario 3b. Well, this is equivalent to solving the equation Ax=M for x. And since A is a square matrix, then we know that x=A−1M, provided A−1 exists. If A−1 does exist, then the answer to OP's original question is "Yes, it's always possible." If A−1 does not exist, then the answer to OP's original question is "No, it's not always possible." So how do we know whether or not A−1 exists? Since A is a square matrix then we can just calculate its determinant. This is hilariously nontrivial (to do by hand) for a 20×20 matrix. Computers to the rescue! Using Maple, we see that the determinant of this matrix is 55, and 55 modulo 4 is 3, which means A is invertible. Therefore A−1 exists, so we can always write x=A−1M. (Side note: Some care needs to be taken when dealing with the determinant modulo 4. It's not enough to just have the determinant be nonzero. A discussion is beyond the scope of this post, but see the comment thread on this answer for some details.)
Proof of equivalency between scenario 1 and scenario 2:
We'll show that each scenario implies the other. Let's first suppose scenario 1 is true, i.e., if we have any two given configuration of lights, then each can reach the other. Since this is possible for any two configurations, then we can simply fix one of the configurations to have all blue lights (ABL). Since the other configuration can be any configuration we want, then we see that any configuration we want can reach ABL. This shows that scenario 1 implies scenario 2.
Now suppose scenario 2 holds. Then for any two light configurations we have, we know that each can reach ABL. Therefore for one configuration C1 to reach any other configuration C2, all we need to do is get C1 to ABL, and then follow the C2's path to ABL "backwards" so that we go from ABL to C2. Therefore scenario 2 implies scenario 1.
No comments:
Post a Comment