This is an incorrect solution. For example, suppose dx = [0,1,0,-1], dy = [2,0,2,0], x = 1 and y = 5 (which is the same situation as test #1 but with a slightly different dy); then this code would return 'True' when in fact the correct answer would obviously be 'False'.
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 =
logical
1
|
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 =
logical
0
|
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 =
logical
0
|
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 =
logical
1
|
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 =
logical
1
|
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 =
logical
0
|
Arrange Vector in descending order
4074 Solvers
What is the distance from point P(x,y) to the line Ax + By + C = 0?
277 Solvers
Convert a vector into a number
503 Solvers
Matrix with different incremental runs
249 Solvers
367 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!