Cody

# Problem 1133. Go-style solver

Solution 1690540

Submitted on 11 Dec 2018 by James
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
board=[1 0 0 1; 0 0 0 1; 0 0 1 0]; y_correct=6; assert(isequal(taking_liberties(board),y_correct))

up = 1 2 up = 3 4 up = 1 5 up = 2 5 u = 1 2 2 1 2 0 2 1 0 2 1 2 number_of_pieces = 6

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

up = 1 2 up = 2 3 up = 3 4 up = 4 5 up = 5 6 up = 6 7 up = 7 8 u = 1 2 0 0 0 0 0 2 1 2 0 0 0 0 0 2 1 2 0 0 0 0 0 2 1 2 0 0 0 0 0 2 1 2 0 0 0 0 0 2 1 2 0 0 0 0 0 2 1 number_of_pieces = 12

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

up = 1 2 up = 4 3 up = 4 4 up = 1 5 u = 1 2 2 1 2 0 0 2 0 2 2 0 2 1 1 2 number_of_pieces = 8

4   Pass

up = 2 3 up = 4 3 up = 6 3 up = 8 3 up = 3 4 up = 4 4 up = 7 4 up = 8 4 up = 2 5 up = 3 5 up = 6 5 up = 7 5 up = 5 6 up = 6 6 up = 7 6 up = 8 6 up = 2 7 up = 4 7 up = 5 7 up = 7 7 up = 3 8 up = 4 8 up = 5 8 up = 6 8 up = 2 9 up = 3 9 up = 5 9 up = 8 9 u = 0 2 0 2 0 2 0 2 2 1 2 1 2 1 2 1 0 2 1 1 2 2 1 1 2 1 1 2 2 1 1 2 0 2 2 2 1 1 1 1 2 1 2 1 1 2 1 2 0 2 1 1 1 1 2 2 2 1 1 2 1 2 2 1 number_of_pieces = 29

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

up = 1 2 up = 2 2 up = 3 2 up = 4 2 up = 1 3 up = 2 3 up = 3 3 up = 4 3 up = 1 4 up = 2 4 up = 3 4 up = 4 4 up = 1 5 up = 2 5 up = 3 5 up = 4 5 u = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 number_of_pieces = 0

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

up = 1 2 up = 6 2 up = 2 3 up = 3 4 up = 6 4 up = 4 5 up = 5 6 up = 6 6 u = 1 2 0 0 0 2 1 2 0 0 0 2 1 2 0 0 0 2 1 2 2 0 2 2 1 1 2 1 2 1 number_of_pieces = 12