Cody

# Problem 44455. Find the average of a random sequance

Solution 1415279

Submitted on 12 Jan 2018 by nadav regev
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))

X = 4 i = 0 count = 0 i = 4 count = 1 X = 7 i = 11 count = 2 X = 0 average = 5.5000 5.5000

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

X = 4 i = 0 count = 0 i = 4 count = 1 X = 0 average = 4 4

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

X = 6 i = 0 count = 0 i = 6 count = 1 X = 7 i = 13 count = 2 X = 3 i = 16 count = 3 X = 5 i = 21 count = 4 X = 9 i = 30 count = 5 X = 9 i = 39 count = 6 X = 1 i = 40 count = 7 X = 2 i = 42 count = 8 X = 0 average = 5.2500 5.2500

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

X = 0 i = 0 count = 0 average = 0 0

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

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