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 six moves to solve. However, now wrapping of the lights occurs. For example, if
board = [1 0 0 0 1
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
1 0 0 0 1]
the answer is:
moves = [1 5 11 15 21 25]
Prev.: 5x5, light-only solution? II —
Next: 5x5, wrapping, x moves
The first test suite problem is troublesome because it requires only 3 moves, and the 3-move solution is not necessarily the first one it finds that has 6 moves or less.
...also, how does the assert(numel(moves)==6) work on the problem that has only 3 moves?
@William: the troublesome test case has been removed. Thanks for pointing that out.
some cases admit shorter solution ^^'
Return the Fibonacci Sequence
Is X a Fibonacci Matrix?
Add two numbers
5 Prime Numbers
Scrabble Scores - 3
Legend of Zelda - Rupee Count
Divisible by 5
Lights Out 2 - 5x5, 4 moves
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office