Cody

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

Solution 3298018

Submitted on 20 Oct 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)

a = 2 4 8 16

Error using assert The condition input argument must be convertible to a scalar logical. Error in Test1 (line 3) assert(abs(a-y_correct)<1e-10)

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

a = 1 3 9 27 81 243 729 2187 6561

Error using assert The condition input argument must be convertible to a scalar logical. Error in Test2 (line 3) assert(abs(a-y_correct)<1e-10)

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)

a = 4 16 256 4096 65536

Error using assert The condition input argument must be convertible to a scalar logical. Error in Test3 (line 3) assert(abs(a-y_correct)<1e-10)

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

a = 1 1 1 1 1 1

Error using assert The condition input argument must be convertible to a scalar logical. Error in Test4 (line 3) assert(abs(a-y_correct)<1e-10)

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)

Error using assert The condition input argument must be convertible to a scalar logical. Error in Test5 (line 7) assert(abs(y-y_correct)<1e-3)

Suggested Problems

More from this Author80

Community Treasure Hunt

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

Start Hunting!