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.
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.
Find all elements less than 0 or greater than 10 and replace them with NaN
given 3 sides, find area of this triangle
Find the sum of the elements in the "second" diagonal
Who knows the last digit of pi?
Wrapping the Tower of Pisa
Would Homer Like It?
Find a subset that divides the vector into equal halves
Cell Counting: How Many Draws?
Make a run-length companion vector
Remove the air bubbles
Find the treasures in MATLAB Central and discover how the community can help you!
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