Solutions to Lights Out
July 21, 2008 personal mathematics
I’ll briefly introduce the Lights Out puzzle: the game is played on an n-by-n grid of buttons which, when pressed, toggle between a lit and unlit state. The twist is that toggling a light also toggles the state of its neighbors (above, below, right, left—although, on the boundary, lights have fewer neighbors). All the buttons are lit when the game begins, and the goal is to turn all the lights off.
There are two key observations:
- toggling a light twice amounts to doing nothing,
- toggling light and then light has the same effect as toggling and then toggling .
<%= movie( ‘lights-out.m4v’, 400, 400 ) %>
For as cool as that looks, there’s not much to be discovered (as far as I can tell) from watching these frames flash by. But it does look like about half the buttons have to be pressed to solve the puzzle: why is that?
The still frames of the movie are available here as PNGs in a zipped archive. Here is a solution to the 400-by-400 board:
Finding that solution involved row-reducing a -by- matrix—that’s a matrix with over 25 billion entries. On the other hand, each entry is one bit, so that matrix fits (not coincidentally) in 3 gigabytes of memory. One could surely do better, considering how sparse the matrix is: perhaps we could have a little contest for solving very large Lights Out games.
Besides the fact that all these pictures look awesome, Lights Out is a neat example to motivate some linear algebra over a finite field. It illustrates how satisfying an “easy” local condition (each light must be turned off) might require a globally complicated solution—a lesson for mathematics and for life!