Cody

# Problem 44455. Find the average of a random sequance

Solution 2092799

Submitted on 14 Jan 2020 by Steven Beumer
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))

z = 4 t = 4 z = 7 t = 4 7 z = 0 t = 4 7 0 average = 5.5000

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

z = 4 t = 4 z = 0 t = 4 0 average = 4

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

z = 6 t = 6 z = 7 t = 6 7 z = 3 t = 6 7 3 z = 5 t = 6 7 3 5 z = 9 t = 6 7 3 5 9 z = 9 t = 6 7 3 5 9 9 z = 1 t = 6 7 3 5 9 9 1 z = 2 t = 6 7 3 5 9 9 1 2 z = 0 t = 6 7 3 5 9 9 1 2 0 average = 5.2500

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

z = 0 t = 0 average = NaN

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

z = 8 t = 8 z = 9 t = 8 9 z = 1 t = 8 9 1 z = 10 t = 8 9 1 10 z = 6 t = 8 9 1 10 6 z = 1 t = 8 9 1 10 6 1 z = 3 t = 8 9 1 10 6 1 3 z = 6 t = 8 9 1 10 6 1 3 6 z = 10 t = 8 9 1 10 6 1 3 6 10 z = 10 t = 8 9 1 10 6 1 3 6 10 10 z = 1 t = 8 9 1 10 6 1 3 6 10 10 1 z = 10 t = 8 9 1 10 6 1 3 6 10 10 1 10 z = 10 t = 8 9 1 10 6 1 3 6 10 10 1 10 10 z = 5 t = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 z = 8 t = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 z = 1 t = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 z = 4 t = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 4 z = 10 t = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 4 10 z = 8 t = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 4 10 8 z = 10 t = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 4 10 8 10 z = 7 t = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 4 10 8 10 7 z = 0 t = 8 9 1 10 6 1 3 6 10 10 1 10 10 5 8 1 4 10 8 10 7 0 average = 6.5714

### Community Treasure Hunt

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

Start Hunting!