Cody

# Problem 45332. Castling-03

Solution 2188906

Submitted on 2 Apr 2020 by Binbin Qi
• Size: 78
• 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
a={'Rd1','Rh1','Ke1'} b={'Nc6','Bg1','g5','Rh8'} assert(isequal(castling_03(a,b),0))

a = 1×3 cell array {'Rd1'} {'Rh1'} {'Ke1'} b = 1×4 cell array {'Nc6'} {'Bg1'} {'g5'} {'Rh8'}

2   Pass
a={'Rd1','Rh1','Ke1'} b={'Nc6','d3','g5','Rh8','Qb8'} assert(isequal(castling_03(a,b),1))

a = 1×3 cell array {'Rd1'} {'Rh1'} {'Ke1'} b = 1×5 cell array {'Nc6'} {'d3'} {'g5'} {'Rh8'} {'Qb8'}

3   Pass
a={'Qe1','Rh1','Kd2','Nf7'} b={'Nc6','d3','g5','Rh8','Qb8'} assert(isequal(castling_03(a,b),0))

a = 1×4 cell array {'Qe1'} {'Rh1'} {'Kd2'} {'Nf7'} b = 1×5 cell array {'Nc6'} {'d3'} {'g5'} {'Rh8'} {'Qb8'}

4   Pass
a={'Qe1','Rh1','Kd2','Nf7'} b={'Nc6','d3','g5','Rh8','Qc1'} assert(isequal(castling_03(a,b),0))

a = 1×4 cell array {'Qe1'} {'Rh1'} {'Kd2'} {'Nf7'} b = 1×5 cell array {'Nc6'} {'d3'} {'g5'} {'Rh8'} {'Qc1'}

5   Pass
a={'Qf1','Rh1','Ra1','Ke1'} b={'Ng1','h3','Rg5','Nb1','Qa8'} assert(isequal(castling_03(a,b),0))

a = 1×4 cell array {'Qf1'} {'Rh1'} {'Ra1'} {'Ke1'} b = 1×5 cell array {'Ng1'} {'h3'} {'Rg5'} {'Nb1'} {'Qa8'}

6   Pass
a={'Qf1','Rh1','Ra1','Ke1'} b={'Ng1','h3','Rg5','Nb5','Qa8'} assert(isequal(castling_03(a,b),1))

a = 1×4 cell array {'Qf1'} {'Rh1'} {'Ra1'} {'Ke1'} b = 1×5 cell array {'Ng1'} {'h3'} {'Rg5'} {'Nb5'} {'Qa8'}

7   Pass
a={'Qf1','Rh1','Ra1','Ke1'} b={'Ba8','Bg7','Rh6','Rb2'} assert(isequal(castling_03(a,b),1))

a = 1×4 cell array {'Qf1'} {'Rh1'} {'Ra1'} {'Ke1'} b = 1×4 cell array {'Ba8'} {'Bg7'} {'Rh6'} {'Rb2'}

### Community Treasure Hunt

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

Start Hunting!