Cody

Problem 44779. Don't be mean. Be nice!

Solution 2991322

Submitted on 25 Sep 2020
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
R=1:4;k=2;y_correct = 27.5; a=dont_be_mean(R,k) assert(abs(a-y_correct)<1e-10)

n = 4 ave = 2.5000 ave2 = 2.5000 ave3 = 2.5000 m = 0 y = 25 a = 25

Assertion failed.

2   Fail
R=0:8;k=3;y_correct = 493.3125; a=dont_be_mean(R,k) assert(abs(a-y_correct)<1e-10)

n = 9 ave = 4 ave2 = 4.5000 ave3 = 3.9375 m = 1 y = 453.9375 a = 453.9375

Assertion failed.

3   Fail
R=[1 2 4 6 8];k=4;y_correct = 4666.2; a=dont_be_mean(R,k) assert(abs(a-y_correct)<1e-10)

n = 5 ave = 4.2000 ave2 = 4.2000 ave3 = 4.2000 m = 3 y = 4.2126e+03 a = 4.2126e+03

Assertion failed.

4   Pass
R=[2 8 6 7 4 5];k=1;y_correct = 5.33333333333333; a=dont_be_mean(R,k) assert(abs(a-y_correct)<1e-10)

n = 6 ave = 5.3333 ave2 = 5.3333 ave3 = 5.3333 m = 0 y = 5.3333 a = 5.3333

5   Fail
R=0:9; y=0; for k=1:8 y=y+dont_be_mean(R,k); end y_correct=61042519.44444444; assert(abs(y-y_correct)<1e-3)

n = 10 ave = 4.5000 ave2 = 5 ave3 = 4.4444 m = 0 y = 5 n = 10 ave = 4.5000 ave2 = 5 ave3 = 4.4444 m = 0 y = 50 n = 10 ave = 4.5000 ave2 = 5 ave3 = 4.4444 m = 1 y = 504.4444 n = 10 ave = 4.5000 ave2 = 5 ave3 = 4.4444 m = 3 y = 5.0133e+03 n = 10 ave = 4.5000 ave2 = 5 ave3 = 4.4444 m = 6 y = 5.0027e+04 n = 10 ave = 4.5000 ave2 = 5 ave3 = 4.4444 m = 10 y = 5.0004e+05 n = 10 ave = 4.5000 ave2 = 5 ave3 = 4.4444 m = 15 y = 5.0001e+06 n = 10 ave = 4.5000 ave2 = 5 ave3 = 4.4444 m = 21 y = 5.0000e+07

Assertion failed.