Cody

Problem 45237. Queen's move - 02

Solution 2069275

Submitted on 26 Dec 2019 by Binbin Qi
• Size: 157
• 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={'Qd1','Qh1','Qh8','Qd5','Qg5','Qc5','Qa7','Qf2','Qe7','Qh7'}; p={'Kd4','Ke5','Kh7','Ke7'}; y_correct = [1,1,0,1,0,1,1,0,0,0]; assert(isequal(Queen_move_3(x,p),y_correct))

2   Pass
x={'Qd1','Qd5','Qf1','Qa8','Qf7','Qb2','Qc7'}; p={'Kd4','Ke5','Kh7','Ke7'}; y_correct = [1,0,1,0,1,0,0]; assert(isequal(Queen_move_3(x,p),y_correct))

3   Pass
x={'Qh7','Qh1','Qh8','Qd5','Qg5','Qc5','Qa7','Qf2','Qe7'}; p={'Kd4','Ke5','Kh7','Ke7'}; y_correct = [0,0,0,0,0,0,0,0,0]; assert(isequal(Queen_move_3(x,p),y_correct))

4   Pass
x={'Qh7','Qh1','Qh8','Qd5','Qg5','Qc5','Qa7','Qf2','Qe7'}; p={'Ka8','Kb2','Kd7','Kf3','Kg6'}; y_correct = [1,1,1,0,0,0,0,0,0]; assert(isequal(Queen_move_3(x,p),y_correct))

5   Pass
x={'Qh7','Qh1','Qd5','Qg5','Qc5','Qa7','Qf2','Qe7','Qg2','Qg7','Qf1','Qf7','Qf2','Qa2'}; p={'Ka8','Kb2','Kd7','Kf3','Kg6'}; y_correct = [1,1,0,0,0,0,0,0,1,0,1,0,1,0]; assert(isequal(Queen_move_3(x,p),y_correct))

Community Treasure Hunt

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

Start Hunting!