Cody

Problem 661. Spot the outlier

Solution 1414620

Submitted on 12 Jan 2018 by Kodavati Mahendra
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))

z = 3 0 -3 1 0 1 z = 3 1 -3 1 0 1 z = 0 1 0 1 0 1 outlier = 3 z = 0 1 3 0 -3 2 z = 0 1 3 0 -3 1

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

z = 2.5000 0.3000 -0.5000 1.3000 -0.5000 1.3000 z = -0.5000 1.3000 -0.5000 1.3000 -0.5000 1.3000 outlier = 2 z = -3.0000 1.0000 2.0000 1.6000 -0.5000 1.3000 z = -3.0000 1.0000 2.5000 0.3000 -1.0000 2.6000 z = -3.0000 1.0000 2.5000 0.3000 -0.5000 1.3000

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

z = 0.2000 3.0000 -0.8000 -12.0000 -1.2000 10.0000 1.6000 -4.0000 z = 0.6000 9.0000 -0.8000 -12.0000 -1.2000 10.0000 1.6000 -4.0000 z = 0.4000 6.0000 -0.6000 -9.0000 -1.2000 10.0000 1.6000 -4.0000 z = 0.4000 6.0000 0.2000 3.0000 -2.0000 -2.0000 1.6000 -4.0000 z = 0.4000 6.0000 0.2000 3.0000 -0.8000 -12.0000 0.4000 6.0000 outlier = 5 z = 0.4000 6.0000 0.2000 3.0000 -0.8000 -12.0000 -1.2000 10.0000

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

z = 0 -4 4 6 -6 -3 z = -2 -5 4 6 -6 -3 z = -2 -1 4 2 -6 -3 outlier = 3 z = -2 -1 0 -4 -2 3 z = -2 -1 0 -4 4 6

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

z = 1.0000 1.0000 0.5000 0.5000 0.5000 0.5000 1.0000 1.0000 outlier = 1 z = 0 2.0000 0.5000 0.5000 0.5000 0.5000 1.0000 1.0000 z = -1.0000 1.0000 1.5000 1.5000 0.5000 0.5000 1.0000 1.0000 z = -1 1 1 1 1 1 1 1 z = -1.0000 1.0000 1.0000 1.0000 0.5000 0.5000 1.5000 1.5000 z = -1.0000 1.0000 1.0000 1.0000 0.5000 0.5000 0.5000 0.5000

Suggested Problems

More from this Author50

Community Treasure Hunt

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

Start Hunting!