Cody

# Problem 45336. chess position

Solution 2188924

Submitted on 2 Apr 2020 by Binbin Qi
• Size: 45
• 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
pos={'Qe5','Rb2'} a=[4,1;4,1] assert(isequal(chess_pos(pos),a))

pos = 1×2 cell array {'Qe5'} {'Rb2'} a = 4 1 4 1

2   Pass
pos={'a5','Nb8'} a=[0,1;4,7] assert(isequal(chess_pos(pos),a))

pos = 1×2 cell array {'a5'} {'Nb8'} a = 0 1 4 7

3   Pass
pos={'Ng8'} a=[6;7] assert(isequal(chess_pos(pos),a))

pos = 1×1 cell array {'Ng8'} a = 6 7

4   Pass
pos={'f1','Qb1','Bd9','c3','Rg7'} a=[ 5 1 NaN 2 6; 0 0 NaN 2 6] assert(isequaln(chess_pos(pos),a))

pos = 1×5 cell array {'f1'} {'Qb1'} {'Bd9'} {'c3'} {'Rg7'} a = 5 1 NaN 2 6 0 0 NaN 2 6

5   Pass
pos={'k1','Kc3','Rh9'} a= [NaN 2 NaN NaN 2 NaN] assert(isequaln(chess_pos(pos),a))

pos = 1×3 cell array {'k1'} {'Kc3'} {'Rh9'} a = NaN 2 NaN NaN 2 NaN