←back to thread

82 points raymondtana | 3 comments | | HN request time: 0.672s | 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. Carrok ◴[] No.45542729[source]
Not to be confused with the other grid based light flipping game, Lights Out, from 1995.

https://en.wikipedia.org/wiki/Lights_Out_(game)

Math article https://matroidunion.org/?p=2160

replies(1): >>45544923 #
2. acomjean ◴[] No.45544923[source]
Or 80s Merlin’s Magic square game.

https://en.wikipedia.org/wiki/Merlin_(console)

Which was only 3x3. But red LEDs which were all the rage in handhelds in the 80s.

When learning JavaScript I made a dupe of the Merlin game in JavaScript. It’s really old but still seems to run. Lacks the depth of this game with its larger grid.

https://www.aramcomjean.com/magic_squares.html

replies(1): >>45545349 #
3. noduerme ◴[] No.45545349[source]
Amazing. I had one of these, and playing your version just took me back to the frustration I had figuring out that game when I was 7 years old.