Skip to content

ssp5zone/lightsoff-solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lights Out Solver

A numeric solution written in JavaScript to solve an nxn Lights-Out Game.

The game is fairly simple, where you are given an nxn matrix, each cell representing a bulb. Clicking on a bulb with toggle it and all perpendicular touching cells i.e. up, down, left and right. Initailly some bulbs are on and some are off. The objective - to switch off all the lights.

The standard solving way is a lookup table, but the problem can be converted to a set of linear equations mod 2, since it is just a binary arithematics.

This can be solved by an n2xn2 matrix mutiplication.

On further analysis, we have reduced the problem to gauss elimination on n2xI, thereby giving a faster solution.

Note: The solution can be optimized by post grouping and elimination. I have not done that.

For a game of above 3x3 size, their exists a lot of combinations for which their are no solutions. I have not checked that and the solver tries to provide a solution nonetheless. This can be fixed.

Run

Download the repo and open the html in any browser

About

A numeric solution Lights Off Game

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages