Cody

Problem 203. fly fly away

Solution 172202

Submitted on 4 Dec 2012 by J.R.! Menzinger
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
%% dx=[0,1,0,-1]; dy=[1,0,1,0]; x=1; y=5; assert(isequal(flyaway(dx,dy,x,y),true))

ans = 0 1 1 0 1 1 2 2

2   Pass
%% dx=[0,1,0,-1]; dy=[1,0,1,0]; x=2; y=5; assert(isequal(flyaway(dx,dy,x,y),false))

ans = 0 1 1 0 1 1 2 2

3   Pass
%% dx=[-2, 3, 1, 4, 0, 0, 1, 4]; dy=[-7,-5, 4, 6,-1, 4, 7, 1]; x=865; y=711; assert(isequal(flyaway(dx,dy,x,y),false))

ans = -2 1 2 6 6 6 7 11 -7 -12 -8 -2 -3 1 8 9

4   Pass
%% dx=[-2, 3, 1, 4, 0, 0, 1, 4]; dy=[-7,-5, 4, 6,-1, 4, 7, 1]; x=865; y=710; assert(isequal(flyaway(dx,dy,x,y),true))

ans = -2 1 2 6 6 6 7 11 -7 -12 -8 -2 -3 1 8 9

5   Pass
%% dx=[-1,-1,-1, 2,-1, 6]; dy=[-1,-2, 2, 1, 1,-6]; x=53; y=-71; assert(isequal(flyaway(dx,dy,x,y),true))

ans = -1 -2 -3 -1 -2 4 -1 -3 -1 0 1 -5

6   Pass
%% dx=[-1,-1,-1, 2,-1, 6]; dy=[-1,-2, 2, 1, 1,-6]; x=50; y=-75; assert(isequal(flyaway(dx,dy,x,y),false))

ans = -1 -2 -3 -1 -2 4 -1 -3 -1 0 1 -5

Suggested Problems

More from this Author38

Community Treasure Hunt

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

Start Hunting!