Problem 45427. King's Cage

Solution 3044098

Submitted on 3 Oct 2020 by Payam Morsali
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))

i = 4

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

i = 4

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

i = 4

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

i = 6

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

i = 7

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

i = 7

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

i = 0

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

i = 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!