Cody

# Problem 45336. chess position

Solution 2173150

Submitted on 24 Mar 2020 by Nikolaos Nikolaou
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 t = 0×0 empty cell array gridR = 1×2 cell array {'e'} {'b'}

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 t = 0×0 empty cell array gridR = 1×2 cell array {'a'} {'b'}

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

pos = 1×1 cell array {'Ng8'} a = 6 7 t = 0×0 empty cell array gridR = 1×1 cell array {'g'}

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 t = 0×0 empty cell array gridR = 1×5 cell array {'f'} {'b'} {'d'} {'c'} {'g'} 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 t = 1×1 cell array {'k'} gridR = 1×3 cell array {'k'} {'c'} {'h'} a = NaN 2 7 NaN 2 8 a = NaN 2 NaN NaN 2 NaN