Cody

# Problem 661. Spot the outlier

Solution 1935861

Submitted on 14 Sep 2019
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 = [0 1; 0 2; 3 2; 0 3; 0 4 ]; outlier = 3; assert(isequal(spot_the_outlier(pts),outlier))

k = 1 u = 0 0 0 v = 4 1 2 aa = 0 0 ans = logical 1 a = 0

`  `
2   Fail
pts = [10 -1;7 0;9.5 0.3;9 1.6;8.5 2.9]; outlier = 2; assert(isequal(spot_the_outlier(pts),outlier))

k = 1 u = 8.5000 10.0000 7.0000 v = 2.9000 -1.0000 0 aa = -0.3846 -3.0000 ans = logical 0 k = 2 u = 10.0000 7.0000 9.5000 v = -1.0000 0 0.3000 aa = -3.0000 8.3333 ans = logical 0 k = 3 u = 7.0000 9.5000 9.0000 v = 0 0.3000 1.6000 aa = 8.3333 -0.3846 ans = logical 0 k = 4 u = 9.5000 9.0000 8.5000 v = 0.3000 1.6000 2.9000 aa = -0.3846 -0.3846 ans = logical 0 k = 5 u = 9.0000 8.5000 10.0000 v = 1.6000 2.9000 -1.0000 aa = -0.3846 -0.3846 ans = logical 0

Undefined function or variable 'a'. Error in spot_the_outlier (line 18) if (x(k)-x(k+1))/(y(k)-y(k+1))~=a Error in Test2 (line 3) assert(isequal(spot_the_outlier(pts),outlier))

`  `
3   Fail
pts = [-0.6 -6;-0.2 0;0 3;-0.8 -9;-2 1;-0.4 -3]; outlier = 5; assert(isequal(spot_the_outlier(pts),outlier))

k = 1 u = -0.4000 -0.6000 -0.2000 v = -3 -6 0 aa = 0.0667 0.0667 ans = logical 0 k = 2 u = -0.6000 -0.2000 0 v = -6 0 3 aa = 0.0667 0.0667 ans = logical 1 a = 0.0667

Assertion failed.

`  `
4   Pass
pts = [2 5;0 4;0 0;4 6;-2 3]; outlier = 3; assert(isequal(spot_the_outlier(pts),outlier))

k = 1 u = -2 2 0 v = 3 5 4 aa = 2 2 ans = logical 1 a = 2

`  `
5   Pass
pts = [1 0; 0 1; 1 2; 1.5 2.5; 2 3; 3 4 ]; outlier = 1; assert(isequal(spot_the_outlier(pts),outlier))

k = 1 u = 3 1 0 v = 4 0 1 aa = 0.5000 -1.0000 ans = logical 0 k = 2 u = 1 0 1 v = 0 1 2 aa = -1 1 ans = logical 0 k = 3 u = 0 1.0000 1.5000 v = 1.0000 2.0000 2.5000 aa = 1 1 ans = logical 1 a = 1

`  `