Problem 44756. Lights Out 5 - 5x5, 10 moves
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
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
Solution Comments
Show commentsProblem Recent Solvers14
Suggested Problems
-
Back to basics 23 - Triangular matrix
1015 Solvers
-
Make an awesome ramp for a tiny motorcycle stuntman
661 Solvers
-
444 Solvers
-
Convert a vector into a number
601 Solvers
-
Find the next Fibonacci number
717 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!