←back to thread

82 points raymondtana | 1 comments | | HN request time: 0.267s | source

"Lights Out" is a mathematical puzzle that lives on an grid where each cell of the grid is one of two colors: either red or white. The goal is to eventually get all the cells in the grid to be red.

What's the catch? Clicking a cell will not only flip its color, but also that of all cells sharing the same row or column as it.

To me, this game feels like playing with a Rubik's cube --- every time you think you are fixing one cell, you mess up its neighbors!

There are many ways to arrive at a solution... some mathematical (linear algebra, or combinatorics), others more logical,... and yet others which are brute force.

The title “Lights Out” comes from a classic handheld game from 1997. The “rule” they follow for which-cells-get-flipped-on-click is what I call “Adjacent.” Additionally, my mathematics teacher showed me this game following another variant which I call “Same Row & Column,” but on a bigger board. He had worked out an algorithm for his version. I found the same strategy before he revealed the answer, and I feel that the process of discovering a solution is quite rewarding—it’s fundamentally related to computing on restrictive computer architectures.

I implemented this app with pretty basic TypeScript. It’s been used for some experiments to discover more general of strategies for different click variants, board sizes, and even board dimensions! It has also been the basis for the corresponding video produced using the Python library manim.

Try it out and let me know how you do!

1. hatthew ◴[] No.45543638[source]
A straightforward solution for larger puzzles: if you click on the four corners of a rectangle, you flip those corners while leaving the rest of the rows/columns the way they started. So after you pick the low hanging fruit at the start, find any rectangle with 3 or 4 white corners, and then click on all 4 corners of that rectangle. If this leaves you with a just one white in each row and column, it's easy and doesn't require memorization to click each of those whites to get to the solved state.