Cody

Problem 44639. Calculate mean value of any pair in a vector.

Solution 1983154

Submitted on 20 Oct 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   Fail
x = [1, 5, 6, 8, 9, 15]; y_correct = [3, 5.5, 7, 8.5, 12] ; assert(isequal(pair_mean(x),y_correct))

y = 2 1 1 2 3 1 1 3 4 1 1 4 5 1 1 5 6 1 1 6 3 2 2 3 4 2 2 4 5 2 2 5 6 2 2 6 4 3 3 4 5 3 3 5 6 3 3 6 5 4 4 5 6 4 4 6 6 5 5 6

Assertion failed.

2   Fail
x = [4 5 21 6 2 1 6 63]; y_correct = [4.5, 13, 13.5, 4, 1.5, 3.5, 34.5] ; assert(isequal(pair_mean(x),y_correct))

y = 2 1 1 2 3 1 1 3 4 1 1 4 5 1 1 5 6 1 1 6 7 1 1 7 8 1 1 8 3 2 2 3 4 2 2 4 5 2 2 5 6 2 2 6 7 2 2 7 8 2 2 8 4 3 3 4 5 3 3 5 6 3 3 6 7 3 3 7 8 3 3 8 5 4 4 5 6 4 4 6 7 4 4 7 8 4 4 8 6 5 5 6 7 5 5 7 8 5 5 8 7 6 6 7 8 6 6 8 8 7 7 8

Assertion failed.

3   Fail
x = [1 1 1 0 0 1 0 1]; y_correct = [1.0000 1.0000 0.5000 0 0.5000 0.5000 0.5000] ; assert(isequal(pair_mean(x),y_correct))

y = 2 1 1 2 3 1 1 3 4 1 1 4 5 1 1 5 6 1 1 6 7 1 1 7 8 1 1 8 3 2 2 3 4 2 2 4 5 2 2 5 6 2 2 6 7 2 2 7 8 2 2 8 4 3 3 4 5 3 3 5 6 3 3 6 7 3 3 7 8 3 3 8 5 4 4 5 6 4 4 6 7 4 4 7 8 4 4 8 6 5 5 6 7 5 5 7 8 5 5 8 7 6 6 7 8 6 6 8 8 7 7 8

Assertion failed.

4   Fail
x = [1 100 1000 10000]; y_correct = [0.0505 0.5500 5.5000] *1000; assert(isequal(pair_mean(x),y_correct))

y = 2 1 1 2 3 1 1 3 4 1 1 4 3 2 2 3 4 2 2 4 4 3 3 4

Assertion failed.

Suggested Problems

More from this Author18

Community Treasure Hunt

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

Start Hunting!