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.
This problem contains boards that each require ten moves to solve. For example, if
board = [0 1 1 0 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
0 1 1 0 1]an answer is:
moves = [1 2 3 4 5 16 17 18 19 20]
Prev.: 5x5, 8 moves — Next: 5x5, 13 moves
Solution Stats
Problem Comments
8 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers18
Suggested Problems
-
What is the distance from point P(x,y) to the line Ax + By + C = 0?
554 Solvers
-
Is this triangle right-angled?
6388 Solvers
-
Split bread like the Pharaohs - Egyptian fractions and greedy algorithm
92 Solvers
-
Check that number is whole number
5184 Solvers
-
920 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!
There seems to be a problem with Lights Out 5. Test cases 4 and 11 can be solved in fewer than 10 moves. Case 4 is solved by [1 3 5 21 23 25], which is easily verified by hand. Case 11 takes 9 moves -- [1 3 7 12 15 16 22 24 25].
@goc
1 William is right.
2 Next problem of this series could be "Lights Out - 5x5, from 3 to 10 moves", I think it is more difficult than this one.
@goc3 Sorry for misspell your name, but I can not delete the comment because of bug of cody.
@William: thanks for catching that. Actually, test case 4 was intentional, as it can also be solved in 10 moves. But, to prevent future confusion, I have replaced it. And, test case 11 was indeed an error—it has been fixed.
@li haitao: the test suite has been updated. Also, problem #7 in the series (not out yet, but will be soon) is similar to what you suggest. Thanks for the comments.
@goc3
A piece of advice, measure the running time(using tic, toc, for example) in the test suit to see which solution is fast.
@li haitao: I got 3.838179s (total time for test suite) for William's solution and 0.986936s (1/4 the time) for your sped-up version. Impressive.
i am surprised about the fact that some test admit a shorter solution than 10 moves :S