Cody

# Problem 44455. Find the average of a random sequance

Solution 1385584

Submitted on 19 Dec 2017 by Jacob Lavzin
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 = 4 i = 1 n = 7 i = 2 n = 0 average = 5.5000

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

n = 4 i = 1 n = 0 average = 4

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

n = 6 i = 1 n = 7 i = 2 n = 3 i = 3 n = 5 i = 4 n = 9 i = 5 n = 9 i = 6 n = 1 i = 7 n = 2 i = 8 n = 0 average = 5.2500

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

n = 0 average = 0

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

n = 8 i = 1 n = 9 i = 2 n = 1 i = 3 n = 10 i = 4 n = 6 i = 5 n = 1 i = 6 n = 3 i = 7 n = 6 i = 8 n = 10 i = 9 n = 10 i = 10 n = 1 i = 11 n = 10 i = 12 n = 10 i = 13 n = 5 i = 14 n = 8 i = 15 n = 1 i = 16 n = 4 i = 17 n = 10 i = 18 n = 8 i = 19 n = 10 i = 20 n = 7 i = 21 n = 0 average = 6.5714