Cody

Solution 2069381

Submitted on 26 Dec 2019 by Binbin Qi
  • Size: 63
  • This is the leading solution.
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='Kg7'; p={'Qe5','Qg5','Qb5','Qa7'} y_correct = [1,1,0,1]; assert(isequal(checkmate(x,p),y_correct))

p = 1×4 cell array {'Qe5'} {'Qg5'} {'Qb5'} {'Qa7'}

2   Pass
x='Kg7'; p={'Qe5','Rg5','Bb5','Na7','h6'} y_correct = [1,1,0,0,1]; assert(isequal(checkmate(x,p),y_correct))

p = 1×5 cell array {'Qe5'} {'Rg5'} {'Bb5'} {'Na7'} {'h6'}

3   Pass
x='Ka3'; p={'Qe5','Rg5','Bb5','Na7','h6'} y_correct = [0,0,0,0,0]; assert(isequal(checkmate(x,p),y_correct))

p = 1×5 cell array {'Qe5'} {'Rg5'} {'Bb5'} {'Na7'} {'h6'}

4   Pass
x='Ka3'; p={'a2','Rg5','Be7','Nc4','Nb1'} y_correct = [0,0,1,1,1]; assert(isequal(checkmate(x,p),y_correct))

p = 1×5 cell array {'a2'} {'Rg5'} {'Be7'} {'Nc4'} {'Nb1'}

5   Pass
x='Ka3'; p={'a2','Rg5','Be7','Nc5','Kb2'} y_correct = [0,0,1,0,0]; assert(isequal(checkmate(x,p),y_correct))

p = 1×5 cell array {'a2'} {'Rg5'} {'Be7'} {'Nc5'} {'Kb2'}

6   Pass
x='Kf2'; p={'Ra2','Rg5','Bh4','Bg1','Nd3','Kf3','Ng1','e1','Qg4','Qf7'} y_correct = [1,0,1,1,1,0,0,0,0,1]; assert(isequal(checkmate(x,p),y_correct))

p = 1×10 cell array {'Ra2'} {'Rg5'} {'Bh4'} {'Bg1'} {'Nd3'} {'Kf3'} {'Ng1'} {'e1'} {'Qg4'} {'Qf7'}

Suggested Problems

More from this Author145