Cody

# Problem 44480. The average of the second largest values

Solution 1407480

Submitted on 6 Jan 2018 by Bob Tivnan
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
x = [1 2 3 4;8 7 6 5;9 0 1 4]; y_correct = (3 + 7 + 4) / 3; assert(isequal(ave_2ndM(x),y_correct))

a = 3 b = 4 x = 1 2 3 4 8 7 6 5 9 0 1 4 x = 1 2 3 4 5 6 7 8 9 0 1 4 x = 1 2 3 4 5 6 7 8 0 1 4 9 y = 4.6667

2   Pass
x = [2 4 ;5 9; 0 5;88 52]; y_correct = (2 + 5 + 0 + 52) / 4; assert(isequal(ave_2ndM(x),y_correct))

a = 4 b = 2 x = 2 4 5 9 0 5 88 52 x = 2 4 5 9 0 5 88 52 x = 2 4 5 9 0 5 88 52 x = 2 4 5 9 0 5 52 88 y = 14.7500

3   Pass
x = [97 93 68 58 24 74 55 49 40 24 63 53 46 37 19]; y_correct = (93 + 55 + 53) / 3; assert(isequal(ave_2ndM(x),y_correct))

a = 3 b = 5 x = 24 58 68 93 97 74 55 49 40 24 63 53 46 37 19 x = 24 58 68 93 97 24 40 49 55 74 63 53 46 37 19 x = 24 58 68 93 97 24 40 49 55 74 19 37 46 53 63 y = 67

4   Pass
x = [ 82 65 14 40 44 73 81 18 53 2 15 46 40 42 99 66 44 84 66 17 52 83 81 63 11 98 9 7 30 38]; y_correct = 61.5; assert(isequal(ave_2ndM(x),y_correct))

a = 6 b = 5 x = 14 40 44 65 82 73 81 18 53 2 15 46 40 42 99 66 44 84 66 17 52 83 81 63 11 98 9 7 30 38 x = 14 40 44 65 82 2 18 53 73 81 15 46 40 42 99 66 44 84 66 17 52 83 81 63 11 98 9 7 30 38 x = 14 40 44 65 82 2 18 53 73 81 15 40 42 46 99 66 44 84 66 17 52 83 81 63 11 98 9 7 30 38 x = 14 40 44 65 82 2 18 53 73 81 15 40 42 46 99 17 44 66 66 84 52 83 81 63 11 98 9 7 30 38 x = 14 40 44 65 82 2 18 53 73 81 15 40 42 46 99 17 44 66 66 84 11 52 63 81 83 98 9 7 30 38 x = 14 40 44 65 82 2 18 53 73 81 15 40 42 46 99 17 44 66 66 84 11 52 63 81 83 7 9 30 38 98 y = 61.5000