Cody

# Problem 1684. Identify Reachable Points

Solution 2262589

Submitted on 7 May 2020 by Lawrence Bray
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
Pts=[5 5; 7 9]; dxy=[0 1]; Mxy=unique(Knights(Pts,dxy),'rows'); Mxy_exp =[4 5;5 4;5 6;6 5;6 9;7 8;7 10;8 9]; assert(isequal(Mxy,Mxy_exp))

Mxy = 5 4 5 6 5 4 5 6 Mxy = 5 4 5 6 5 4 5 6 4 5 4 5 6 5 6 5 Mxy = 5 4 5 6 5 4 5 6 4 5 4 5 6 5 6 5 7 8 7 10 7 8 7 10 Mxy = 5 4 5 6 5 4 5 6 4 5 4 5 6 5 6 5 7 8 7 10 7 8 7 10 6 9 6 9 8 9 8 9

2   Pass
Pts=[5 5]; dxy=[0 1;1 2]; Mxy=unique(Knights(Pts,dxy),'rows'); Mxy_exp =[3 4;3 6;4 3;4 5;4 7;5 4;5 6;6 3;6 5;6 7;7 4;7 6]; assert(isequal(Mxy,Mxy_exp))

Mxy = 5 4 5 6 5 4 5 6 Mxy = 5 4 5 6 5 4 5 6 4 5 4 5 6 5 6 5 Mxy = 5 4 5 6 5 4 5 6 4 5 4 5 6 5 6 5 4 3 4 7 6 3 6 7 Mxy = 5 4 5 6 5 4 5 6 4 5 4 5 6 5 6 5 4 3 4 7 6 3 6 7 3 4 3 6 7 4 7 6

3   Pass
pts=randi(20,6,2); dxy=randi(6,4,2); Mxy=unique(Knights(pts,dxy),'rows'); nP=size(pts,1); ndxy=size(dxy,1); mxy=[]; for i=1:nP mxy=[mxy; dxy(:,1)+pts(i,1) dxy(:,2)+pts(i,2); -dxy(:,1)+pts(i,1) dxy(:,2)+pts(i,2); dxy(:,1)+pts(i,1) -dxy(:,2)+pts(i,2); -dxy(:,1)+pts(i,1) -dxy(:,2)+pts(i,2); dxy(:,2)+pts(i,1) dxy(:,1)+pts(i,2); -dxy(:,2)+pts(i,1) dxy(:,1)+pts(i,2); dxy(:,2)+pts(i,1) -dxy(:,1)+pts(i,2); -dxy(:,2)+pts(i,1) -dxy(:,1)+pts(i,2)]; end Mxy_exp=unique(mxy,'rows'); assert(isequal(Mxy,Mxy_exp))

Mxy = 17 8 17 10 21 8 21 10 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 9 15 9 17 13 15 13 17 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 9 15 9 17 13 15 13 17 10 14 10 18 12 14 12 18 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 9 15 9 17 13 15 13 17 10 14 10 18 12 14 12 18 9 14 9 18 13 14 13 18 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 9 15 9 17 13 15 13 17 10 14 10 18 12 14 12 18 9 14 9 18 13 14 13 18 9 14 9 18 13 14 13 18 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 9 15 9 17 13 15 13 17 10 14 10 18 12 14 12 18 9 14 9 18 13 14 13 18 9 14 9 18 13 14 13 18 10 11 10 21 12 11 12 21 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 9 15 9 17 13 15 13 17 10 14 10 18 12 14 12 18 9 14 9 18 13 14 13 18 9 14 9 18 13 14 13 18 10 11 10 21 12 11 12 21 6 15 6 17 16 15 16 17 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 9 15 9 17 13 15 13 17 10 14 10 18 12 14 12 18 9 14 9 18 13 14 13 18 9 14 9 18 13 14 13 18 10 11 10 21 12 11 12 21 6 15 6 17 16 15 16 17 6 14 6 18 16 14 16 18 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 9 15 9 17 13 15 13 17 10 14 10 18 12 14 12 18 9 14 9 18 13 14 13 18 9 14 9 18 13 14 13 18 10 11 10 21 12 11 12 21 6 15 6 17 16 15 16 17 6 14 6 18 16 14 16 18 9 11 9 21 13 11 13 21 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 9 15 9 17 13 15 13 17 10 14 10 18 12 14 12 18 9 14 9 18 13 14 13 18 9 14 9 18 13 14 13 18 10 11 10 21 12 11 12 21 6 15 6 17 16 15 16 17 6 14 6 18 16 14 16 18 9 11 9 21 13 11 13 21 9 19 9 21 13 19 13 21 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 9 15 9 17 13 15 13 17 10 14 10 18 12 14 12 18 9 14 9 18 13 14 13 18 9 14 9 18 13 14 13 18 10 11 10 21 12 11 12 21 6 15 6 17 16 15 16 17 6 14 6 18 16 14 16 18 9 11 9 21 13 11 13 21 9 19 9 21 13 19 13 21 10 18 10 22 12 18 12 22 Mxy = 17 8 17 10 21 8 21 10 18 7 18 11 20 7 20 11 17 7 17 11 21 7 21 11 17 7 17 11 21 7 21 11 18 4 18 14 20 4 20 14 14 8 14 10 24 8 24 10 14 7 14 11 24 7 24 11 17 4 17 14 21 4 21 14 9 15 9 17 13 15 13 17 10 14 10 18 12 14 12 18 9 14 9 18 13 14 13 18 9 14 9 18 13 14 13 18 10 11 10 21 12 11 12 21 6 15 6 17 16 15 16 17 6 14 6 18 16 14 16 18 9 11 9 21 13 11 13 21 9 19 9 21 13 19 13 21 10 18 10 22 12 18 12 22 ...