Cody

Solution 1541568

Submitted on 27 May 2018 by tamir zinger
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
filetext = fileread('MeanWhile.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Pass
filetext = fileread('MeanWhile.m'); assert(isempty(strfind(filetext, 'sum')),'sum() function is forbidden')

3   Pass
filetext = fileread('MeanWhile.m'); assert(isempty(strfind(filetext, 'mean')),'mean() function is forbidden')

4   Pass
rng(1); av_correct = 5.5; assert(isequal(MeanWhile(),av_correct))

n = 0 v = [] i = 1 v = 4 n = 4 i = 2 v = 4 7 n = 11 average = 5.5000

5   Pass
rng(2); av_correct = 4; assert(isequal(MeanWhile(),av_correct))

n = 0 v = [] i = 1 v = 4 n = 4 average = 4

6   Pass
rng(3); av_correct = 5.25; assert(isequal(MeanWhile(),av_correct))

n = 0 v = [] i = 1 v = 6 n = 6 i = 2 v = 6 7 n = 13 i = 3 v = 6 7 3 n = 16 i = 4 v = 6 7 3 5 n = 21 i = 5 v = 6 7 3 5 9 n = 30 i = 6 v = 6 7 3 5 9 9 n = 39 i = 7 v = 6 7 3 5 9 9 1 n = 40 i = 8 v = 6 7 3 5 9 9 1 2 n = 42 average = 5.2500

7   Pass
rng(7); av_correct = 0; assert(isequal(MeanWhile(),av_correct))

n = 0 v = []

8   Pass
rng(0); av_correct = 6.571428571428571; assert(isequal(MeanWhile(),av_correct))

n = 0 v = [] i = 1 v = 8 n = 8 i = 2 v = 8 9 n = 17 i = 3 v = 8 9 1 n = 18 i = 4 v = 8 9 1 10 n = 28 i = 5 v = 8 9 1 10 6 n = 34 i = 6 v = 8 9 1 10 6 1 n = 35 i = 7 v = 8 9 1 10 6 1 3 n = 38 i = 8 v = 8 9 1 10 6 1 3 6 n = 44 i = 9 v = 8 9 1 10 6 1 3 6 10 n = 54 i = 10 v = 8 9 1 10 6 1 3 6 10 10 n = 64 i = 11 v = 8 9 1 10 6 1 3 6 10 10 1 n = 65 i = 12 v = 8 9 1 10 6 1 3 6 10 10 1 10 n = 75 i = 13 v = 8 9 1 10 6 1 3 6 10 10 1 10 10 n = 85 i = 14 v = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 n = 90 i = 15 v = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 n = 98 i = 16 v = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 n = 99 i = 17 v = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 4 n = 103 i = 18 v = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 4 10 n = 113 i = 19 v = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 4 10 8 n = 121 i = 20 v = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 4 10 8 10 n = 131 i = 21 v = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 4 10 8 10 7 n = 138 average = 6.5714