Cody

# Problem 44455. Find the average of a random sequance

Solution 1967260

Submitted on 8 Oct 2019 by Augusto Mazzei
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))

7 4 1 0 11 2 a = 5.5000

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

0 4 1 a = 4

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

7 6 1 3 13 2 5 16 3 9 21 4 9 30 5 1 39 6 2 40 7 0 42 8 a = 5.2500

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

a = NaN a = 0

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

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

### Community Treasure Hunt

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

Start Hunting!