Only works because test suite isn't extensive enough. Wouldn't work with a = [1 0 1; 0 0 0; 0 1 0], for example.
Cheating solution.
This solution has a minor bug, but it fortunately passed the test suite. :-)
It's supposed to be a n-QUEENS checker, not an n-KINGS checker. This solution wouldn't work with a = [1 0 1; 0 0 0; 0 1 0], for example.
Thanks yurenchu! I added your proposed test point to the tests.
test suite needs additional samples that fail due to diagonal movements (e.g. [1,0;0,1])
I added this test. Rescoring now. Thanks for the suggestion.
Project Euler: Problem 6, Natural numbers, squares and sums.
1038 Solvers
Create a function handle that reverses the input arguments of another function handle
124 Solvers
Duplicate each element of a vector.
521 Solvers
Create matrix of replicated elements
325 Solvers
Celsius to Fahrenheit converter
396 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!