Cody

# Problem 44455. Find the average of a random sequance

Solution 2463956

Submitted on 3 Jun 2020 by Othman Salih
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))

s = 4 i = 1 x = 7 s = 11 i = 2 x = 0

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

s = 4 i = 1 x = 0

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

s = 6 i = 1 x = 7 s = 13 i = 2 x = 3 s = 16 i = 3 x = 5 s = 21 i = 4 x = 9 s = 30 i = 5 x = 9 s = 39 i = 6 x = 1 s = 40 i = 7 x = 2 s = 42 i = 8 x = 0

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

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

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