Cody

Solution 2120954

Submitted on 7 Feb 2020
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   Fail
board=[1 0 0 1; 0 0 0 1; 0 0 1 0]; y_correct=6; assert(isequal(taking_liberties(board),y_correct))

newmat = 3 3 3 3 3 3 3 1 0 0 1 3 3 0 0 0 1 3 3 0 0 1 0 3 3 3 3 3 3 3

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in taking_liberties (line 11) if any([newmat(r-1,c),newmat(r+1,c),newmat(r,c-1),newmat(r,c+1)]==1) Error in Test1 (line 3) assert(isequal(taking_liberties(board),y_correct))

2   Fail
board=eye(7); y_correct=12; assert(isequal(taking_liberties(board),y_correct))

newmat = 3 3 3 3 3 3 3 3 3 3 1 0 0 0 0 0 0 3 3 0 1 0 0 0 0 0 3 3 0 0 1 0 0 0 0 3 3 0 0 0 1 0 0 0 3 3 0 0 0 0 1 0 0 3 3 0 0 0 0 0 1 0 3 3 0 0 0 0 0 0 1 3 3 3 3 3 3 3 3 3 3

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in taking_liberties (line 11) if any([newmat(r-1,c),newmat(r+1,c),newmat(r,c-1),newmat(r,c+1)]==1) Error in Test2 (line 3) assert(isequal(taking_liberties(board),y_correct))

3   Fail
board=double(magic(4)>12); y_correct=8; assert(isequal(taking_liberties(board),y_correct))

newmat = 3 3 3 3 3 3 3 1 0 0 1 3 3 0 0 0 0 3 3 0 0 0 0 3 3 0 1 1 0 3 3 3 3 3 3 3

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in taking_liberties (line 11) if any([newmat(r-1,c),newmat(r+1,c),newmat(r,c-1),newmat(r,c+1)]==1) Error in Test3 (line 3) assert(isequal(taking_liberties(board),y_correct))

4   Fail
board=double(hadamard(8)<0); y_correct=29; assert(isequal(taking_liberties(board),y_correct))

newmat = 3 3 3 3 3 3 3 3 3 3 3 0 0 0 0 0 0 0 0 3 3 0 1 0 1 0 1 0 1 3 3 0 0 1 1 0 0 1 1 3 3 0 1 1 0 0 1 1 0 3 3 0 0 0 0 1 1 1 1 3 3 0 1 0 1 1 0 1 0 3 3 0 0 1 1 1 1 0 0 3 3 0 1 1 0 1 0 0 1 3 3 3 3 3 3 3 3 3 3 3

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in taking_liberties (line 11) if any([newmat(r-1,c),newmat(r+1,c),newmat(r,c-1),newmat(r,c+1)]==1) Error in Test4 (line 3) assert(isequal(taking_liberties(board),y_correct))

5   Pass
board=ones(4); y_correct=0; assert(isequal(taking_liberties(board),y_correct))

6   Fail
board=vertcat(eye(5),[1 0 1 0 1]); y_correct=12; assert(isequal(taking_liberties(board),y_correct))

newmat = 3 3 3 3 3 3 3 3 1 0 0 0 0 3 3 0 1 0 0 0 3 3 0 0 1 0 0 3 3 0 0 0 1 0 3 3 0 0 0 0 1 3 3 1 0 1 0 1 3 3 3 3 3 3 3 3

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in taking_liberties (line 11) if any([newmat(r-1,c),newmat(r+1,c),newmat(r,c-1),newmat(r,c+1)]==1) Error in Test6 (line 3) assert(isequal(taking_liberties(board),y_correct))