Problem 45427. King's Cage

Solution 2196803

Submitted on 7 Apr 2020 by Asif Newaz
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x=[1,1]; y=[5,5]; assert(isequal( king(x,y),4))

2   Pass
x=[6,6]; y=[2,3]; assert(isequal( king(x,y),4))

3   Pass
x=[5,1]; y=[5,5]; assert(isequal( king(x,y),4))

4   Pass
x=[2,3]; y=[8,8]; assert(isequal( king(x,y),6))

5   Pass
x=[2,8]; y=[7,1]; assert(isequal( king(x,y),7))

6   Pass
x=[1,4]; y=[8,3]; assert(isequal( king(x,y),7))

7   Pass
x=[5,8]; y=[5,8]; assert(isequal( king(x,y),0))

8   Pass
x=[1,4]; y=[3,4]; assert(isequal( king(x,y),2))

Suggested Problems

More from this Author149

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!