Cody

Problem 661. Spot the outlier

Solution 1027657

Submitted on 22 Oct 2016 by TallBrian
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))

aa = -1.5708 0 -1.2490 0 0 0 -1.5708 1.5708 0 0 0 -0.3218 -0.3218 2.4981 2.2318 0 0 1.2490 -1.5708 0 0 0 0.9828 0 -1.5708 aa = 0 0 -1.2490 0 0 0 0 1.5708 0 0 0 -0.3218 0 2.4981 2.2318 0 0 1.2490 0 0 0 0 0.9828 0 0 s = 0 0.3218 5.0517 2.4981 2.2318 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))

aa = -1.9380 0.8819 0 0 0 2.1451 -0.6747 -0.5553 0 0.4187 0.0000 -1.8185 -1.9380 0 0 0.0000 -1.2632 0.0000 -1.9380 0 0 -0.8445 0 0 -1.9380 aa = 0 0.8819 0 0 0 2.1451 0 -0.5553 0 0.4187 0.0000 -1.8185 0 0 0 0.0000 -1.2632 0.0000 0 0 0 -0.8445 0 0 0 s = 2.1451 4.8082 0.5553 0 0.4187 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))

aa = -1.5042 0 0 0.0000 0.2640 0 0 -1.5042 -0.0000 0 1.1303 0 0 0 -1.5042 0 -0.7188 0 0 0 0 -1.5042 0.1860 0 0.0390 0.9053 -0.9438 -0.0390 -1.7292 0.2221 0 -0.0000 -0.0000 0 0.4471 -1.5042 aa = 0 0 0 0.0000 0.2640 0 0 0 -0.0000 0 1.1303 0 0 0 0 0 -0.7188 0 0 0 0 0 0.1860 0 0.0390 0.9053 -0.9438 -0.0390 0 0.2221 0 -0.0000 -0.0000 0 0.4471 0 s = 0.0390 0.9053 0.9438 0.0390 2.7461 0.2221 outlier = 5

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

aa = -0.4636 0 0.7266 0.0000 0 0 -0.4636 1.1071 0 -0.0000 0 0.3805 -1.1903 -0.2075 0.9685 0 0 0.5191 -0.4636 0 0 0 1.6952 0 -0.4636 aa = 0 0 0.7266 0.0000 0 0 0 1.1071 0 -0.0000 0 0.3805 0 -0.2075 0.9685 0 0 0.5191 0 0 0 0 1.6952 0 0 s = 0 0.3805 4.0481 0.2075 0.9685 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))

aa = -1.3112 1.0450 0.2596 0.0622 -0.0622 -0.2041 1.5708 -0.7854 0 0 0 0 0.7854 0 -0.7854 0 0 0 0.5880 0 0 -0.7854 0 0 0.4636 0 0 0 -0.7854 0 0.3218 0 0 0 0 -0.7854 aa = 0 1.0450 0.2596 0.0622 -0.0622 -0.2041 1.5708 0 0 0 0 0 0.7854 0 0 0 0 0 0.5880 0 0 0 0 0 0.4636 0 0 0 0 0 0.3218 0 0 0 0 0 s = 3.7296 1.0450 0.2596 0.0622 0.0622 0.2041 outlier = 1