Cody

Solution 1996722

Submitted on 30 Oct 2019
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))

board = 1 2 0 1 0 0 0 1 0 0 1 0 board = 1 2 2 1 0 0 0 1 0 0 1 0 board = 2 2 2 1 0 0 0 1 0 0 1 0 board = 2 2 2 1 0 0 0 1 0 0 2 0 board = 2 2 2 1 0 0 2 1 0 0 2 0 board = 2 2 2 1 0 0 2 2 0 0 2 0

Assertion failed.

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

board = 1 2 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 board = 2 2 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 board = 2 2 0 0 0 0 0 0 1 2 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 board = 2 2 0 0 0 0 0 2 1 2 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 board = 2 2 0 0 0 0 0 2 2 2 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 board = 2 2 0 0 0 0 0 2 2 2 0 0 0 0 0 0 1 2 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 board = 2 2 0 0 0 0 0 2 2 2 0 0 0 0 0 2 1 2 0 0 0 0 0 0 1 0 0 0 0 0 0 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0 2 2 2 0 0 0 0 0 0 1 board = 2 2 0 0 0 0 0 2 2 2 0 0 0 0 0 2 2 2 0 0 0 0 0 2 2 2 0 0 0 0 0 2 2 2 0 0 0 0 0 2 2 2 0 0 0 0 0 2 1

Assertion failed.

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

board = 1 2 0 1 0 0 0 0 0 0 0 0 0 1 1 0 board = 1 2 2 1 0 0 0 0 0 0 0 0 0 1 1 0 board = 2 2 2 1 0 0 0 0 0 0 0 0 0 1 1 0 board = 2 2 2 2 0 0 0 0 0 0 0 0 0 1 1 0 board = 2 2 2 2 0 0 0 0 0 0 0 0 0 2 1 0 board = 2 2 2 2 0 0 0 0 0 0 0 0 0 2 2 0

Assertion failed.

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

board = 0 0 0 0 0 0 0 0 0 2 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 1 board = 0 0 0 0 0 0 0 0 0 2 0 2 0 1 0 1 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 1 board = 0 0 0 0 0 0 0 0 0 2 0 2 0 2 0 1 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 1 board = 0 0 0 0 0 0 0 0 0 2 0 2 0 2 0 2 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 1 board = 0 0 0 0 0 0 0 0 0 2 0 2 0 2 0 2 0 0 2 1 0 0 1 1 0 1 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0 0 0 0 0 0 0 2 0 2 0 2 0 2 0 0 2 1 2 0 2 1 0 2 2 2 0 2 1 2 0 0 0 0 2 1 1 1 0 2 0 2 1 2 1 2 0 0 2 1 1 1 2 0 0 2 1 0 1 0 0 2 board = 0 0 0 0 0 0 0 0 0 2 0 2 0 2 0 2 0 0 2 1 2 0 2 1 0 2 2 2 0 2 1 2 0 0 0 0 2 1 1 1 0 2 0 2 1 2 1 2 0 0 2 1 1 1 2 0 0 2 1 2 1 0 0 2 board = 0 0 0 0 0 0 0 0 0 2 0 2 0 2 0 2 0 0 2 1 2 0 2 1 0 2 2 2 0 2 1 2 0 0 0 0 2 1 1 1 0 2 0 2 1 2 1 2 0 0 2 1 1 1 2 0 0 2 1 2 1 2 0 2

Assertion failed.

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

Assertion failed.

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

board = 1 2 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 board = 2 2 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 board = 2 2 0 0 0 0 1 2 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 board = 2 2 0 0 0 2 1 2 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 board = 2 2 0 0 0 2 2 2 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 board = 2 2 0 0 0 2 2 2 0 0 0 0 1 2 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 board = 2 2 0 0 0 2 2 2 0 0 0 2 1 2 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 board = 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 board = 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 0 1 2 0 0 0 0 1 1 0 1 0 1 board = 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 2 1 2 0 0 0 0 1 1 0 1 0 1 board = 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 2 1 2 0 0 0 0 1 2 0 1 0 1 board = 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 2 1 2 0 0 0 0 1 2 0 2 0 1 board = 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 0 1 2 0 2 0 1 board = 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 2 1 2 0 2 0 1 board = 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 0 2 1 2 0 2 2 1

Assertion failed.

Suggested Problems