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
2197 Solvers
657 Solvers
Project Euler: Problem 6, Natural numbers, squares and sums.
1018 Solvers
306 Solvers
Solve the set of simultaneous linear equations
273 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!