Cody

# Problem 1684. Identify Reachable Points

Solution 1985123

Submitted on 22 Oct 2019 by Andrew Newell
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))

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))

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))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!