Lights Out is a logic game wherein all lights need to be turned off to complete each board. See the first problem in the series for an introduction and problem 12 for an explanation of three stages.
This problem contains boards that each require any number of moves to solve. Recall that lights are activated through three stages: on1 (1) to on2 (2) to off (0). For example, if
board = [1 1 0 2 2
1 0 0 0 2
0 0 0 0 0
0 2 2 0 0
2 1 1 2 0]the answer is:
moves = [1 1 10 15 21]
Up to two moves are possible for each button (index).
Prev.: 5x5, 3 stages, <7 moves — Next: 5x5, 4 stages, x moves
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers12
Suggested Problems
-
Calculate the Levenshtein distance between two strings
1512 Solvers
-
163 Solvers
-
1933 Solvers
-
Unique values without using UNIQUE function
453 Solvers
-
Is this is a Tic Tac Toe X Win?
536 Solvers
More from this Author139
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
It took a long time to get to a problem in this group I couldn't brute force, at least after focusing that force, but this one did it. I came up with a strategy which is similar to the one called "chasing the lights" in that it solves one light at a time, but it works in one pass with an endgame cleanup. It does require more data than a person can easily track, but quite easy for a computer. And I came up with it myself in about a day that I was also working. To solve Cody problems, I have done research on the internet, and even once bought a textbook (that didn't help) , but not this time.