frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: Lights Out: my 2D Rubik's Cube-like Game

https://raymondtana.github.io/projects/pages/Lights_Out.html
31•raymondtana•15h ago
"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!

Comments

kevindamm•4h ago
Enjoyable, after getting the hang of the "full rows/cols" variant it became like popping packing bubbles.. I kind of wanted to keep playing with the kaleidoscopic shapes you can make with the near-complete positions.

I'd seen the "adjacent only" variant before but not the other two, I'm glad the default was one I hadn't seen or I might not have noticed there was a choice!

Have you considered allowing the all-white state as a terminal state too? First time I completed it was with a detour to there (I know the text says make them red but my instincts went with the lights-out being to the color matching the background)

Thanks for the diversion. On the 5x5 my scores went from ~100 to dozens (sometimes 8-10). On larger boards I'm not as consistent but also not as interested in path length.

taeric•3h ago
Fun game, kudos!

Calling it a 2d rubik's like makes me wonder if I should try to turn the code at the bottom of https://taeric.github.io/cube-permutations-1.html into a game.

shiandow•3h ago
Once you figure out the trick to the row column puzzle it becomes trivial to solve, except that you need a steady hand.
adamschwartz•2h ago
Memorize which cells are white when the board first loads. Tap all of those in order without regard to the way the board changes as you go.

Edit: above tested for 5x5 rows&cols. For even boards it seems there’s a small end-game to repeat the process — something about parity I assume.

rprenger•2h ago
And you can do that at any board state, so if it starts with like 16 white squares you can make one or two greedy moves to minimize white squares, then do your memorize trick.
adamschwartz•2h ago
Yea that can shave a few moves off.

For fun you can also, for example, invert any board in N moves by tapping every cell straight across any row or column.

o-o-•2h ago
Interesting, and black magic as far as I'm concerned. How does that algorithm translate onto the Rubik's cube (which I evidently never learned to solve)?
patrickdavey•2h ago
Why does that work?
primitivesuave•1h ago
If you think of each button press as a matrix being added to the board state where only the row and column are set to 1, along with the commutative nature of the moves (order doesn't matter), then as long as the total number of "flips" from the cumulative matrices of moves is odd, then it will reset the board.

Mathematically I might say that the system's precomputed solution vector is readily apparent.

0x1ceb00da•1h ago
What if there was only one white block on the grid?
adamschwartz•1h ago
The game is initialized with a guaranteed solvable board:

https://github.com/RaymondTana/Lights_Out/blob/31fe5e866c45c...

owenpalmer•1h ago
I'm glad I got to play it for a bit before learning the trick. Quite a simple and clever puzzle!
Carrok•52m ago
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

Igalia, Servo, and the Sovereign Tech Fund

https://www.igalia.com/2025/10/09/Igalia,-Servo,-and-the-Sovereign-Tech-Fund.html
310•robin_reala•7h ago•48 comments

Google, Meta and Microsoft opts to stop showing political ads in EU

https://www.politico.eu/article/eu-political-ad-rules-google-meta-microsoft-big-tech-kick-in/
91•martinohansen•1h ago•63 comments

Ask HN: What's the best hackable smart TV?

146•xrd•4d ago•111 comments

Lánczos Interpolation Explained (2022)

https://mazzo.li/posts/lanczos.html
14•tobr•5d ago•1 comments

Show HN: I invented a new generative model and got accepted to ICLR

https://discrete-distribution-networks.github.io/
418•diyer22•11h ago•52 comments

Does our "need for speed" make our Wi-Fi suck? Yes.

https://orb.net/blog/does-speed-make-wifi-suck
17•jamies•1h ago•10 comments

Ryanair flight landed at Manchester airport with six minutes of fuel left

https://www.theguardian.com/business/2025/oct/10/ryanair-flight-landed-at-manchester-airport-with...
350•mazokum•5h ago•302 comments

Notes on switching to Helix from Vim

https://jvns.ca/blog/2025/10/10/notes-on-switching-to-helix-from-vim/
211•chmaynard•5h ago•114 comments

OpenGL: Mesh shaders in the current year

https://www.supergoodcode.com/mesh-shaders-in-the-current-year/
97•pjmlp•8h ago•78 comments

NanoMi: Source-available transmission electron microscope

https://nanomi.org/
47•pillars•2d ago•8 comments

The Molecular Basis of Long Covid Brain Fog

https://www.yokohama-cu.ac.jp/english/news/20251001takahashi.html
113•onnnon•5h ago•32 comments

It's OpenAI's world, we're just living in it

https://stratechery.com/2025/its-openais-world-were-just-living-in-it/
63•feross•3h ago•102 comments

Show HN: Gitcasso – Syntax Highlighting and Draft Recovery for GitHub Comments

https://github.com/diffplug/gitcasso
18•etwigg•4h ago•4 comments

All-Natural Geoengineering with Frank Herbert's Dune

https://www.governance.fyi/p/all-natural-geoengineering-with-frank
58•toomuchtodo•6h ago•11 comments

Toyota aims to launch the ' first' all-solid-state EV batteries

https://electrek.co/2025/10/08/toyota-aims-to-launch-worlds-first-all-solid-state-ev-batteries/
20•thelastgallon•1h ago•8 comments

Ohno Type School: A (2020)

https://ohnotype.co/blog/ohno-type-school-a
159•tobr•4d ago•59 comments

My approach to building large technical projects (2023)

https://mitchellh.com/writing/building-large-technical-projects
296•mad2021•16h ago•42 comments

A story about bypassing air Canada's in-flight network restrictions

https://ramsayleung.github.io/en/post/2025/a_story_about_bypassing_air_canadas_in-flight_network_...
147•samray•12h ago•113 comments

Google Safe Browsing incident

https://www.statichost.eu/blog/google-safe-browsing/
152•ericselin•6h ago•121 comments

Weave (YC W25) is hiring a founding AI engineer

https://www.ycombinator.com/companies/weave-3/jobs/SqFnIFE-founding-ai-engineer
1•adchurch•8h ago

Datastar: Lightweight hypermedia framework for building interactive web apps

https://data-star.dev/
179•freetonik•11h ago•190 comments

Examples Are the Best Documentation

https://rakhim.exotext.com/examples-are-the-best-documentation
359•Bogdanp•1d ago•133 comments

Illegible Nature of Software Development Talent

https://surfingcomplexity.blog/2025/10/08/the-illegible-nature-of-software-development-talent/
63•hackthemack•2h ago•58 comments

Show HN: A Digital Twin of my coffee roaster that runs in the browser

https://autoroaster.com/
10•jvkoch•4d ago•1 comments

Show HN: Lights Out: my 2D Rubik's Cube-like Game

https://raymondtana.github.io/projects/pages/Lights_Out.html
31•raymondtana•15h ago•13 comments

You can't build tcc from Nixpkgs if you are in the UK

https://github.com/NixOS/nixpkgs/issues/444342
124•RGBCube•4h ago•55 comments

A Library for Parsing Dutch Smart Meter Requirements (DSMR)

https://github.com/mijnverbruik/dsmr
18•robinvdvleuten•4d ago•3 comments

Origami Patterns Solve a Major Physics Riddle

https://www.quantamagazine.org/origami-patterns-solve-a-major-physics-riddle-20251006/
41•westurner•4d ago•2 comments

"Vibe code hell" has replaced "tutorial hell" in coding education

https://blog.boot.dev/education/vibe-code-hell/
221•wagslane•4h ago•108 comments

Nobel Peace Prize 2025: María Corina Machado

https://www.nobelprize.org/prizes/peace/2025/summary/
528•pykello•11h ago•560 comments