Cody

# Problem 661. Spot the outlier

Solution 432037

Submitted on 15 Apr 2014 by Joel
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))

slopematrix = -Inf slopematrix = -Inf 0 slopematrix = -Inf 0 -0.3333 slopematrix = -Inf 0 -0.3333 -Inf diffslopes = -Inf diffslopes = -Inf 0.3333 diffslopes = -Inf 0.3333 Inf middleindex = 1 2 3 outlier = 3

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

slopematrix = -0.3333 slopematrix = -0.3333 0.1200 slopematrix = -0.3333 0.1200 -2.6000 slopematrix = -0.3333 0.1200 -2.6000 -2.6000 diffslopes = -0.4533 diffslopes = -0.4533 2.7200 diffslopes = -0.4533 2.7200 -0.0000 middleindex = 1 2 3 outlier = 3 outlier = 2

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

slopematrix = 15.0000 slopematrix = 15.0000 15.0000 slopematrix = 15.0000 15.0000 15.0000 slopematrix = 15.0000 15.0000 15.0000 -8.3333 slopematrix = 15.0000 15.0000 15.0000 -8.3333 -2.5000 diffslopes = 1.7764e-15 diffslopes = 1.0e-14 * 0.1776 0 diffslopes = 0.0000 0 23.3333 diffslopes = 0.0000 0 23.3333 -5.8333 outlier = 1 didtheyfire = 2 outlier = 5 didtheyfire = 5

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

slopematrix = 0.5000 slopematrix = 0.5000 Inf slopematrix = 0.5000 Inf 1.5000 slopematrix = 0.5000 Inf 1.5000 0.5000 diffslopes = -Inf diffslopes = -Inf Inf diffslopes = -Inf Inf 1 middleindex = 1 2 3 outlier = 3

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

slopematrix = -1 slopematrix = -1 1 slopematrix = -1 1 1 slopematrix = -1 1 1 1 slopematrix = -1 1 1 1 1 diffslopes = -2 diffslopes = -2 0 diffslopes = -2 0 0 diffslopes = -2 0 0 0 outlier = 1 didtheyfire = 2