Cody

Solution 1306026

Submitted on 20 Oct 2017 by Ashley Goddard
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
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','locOf5.m')

2   Pass
x = 2:2:20; y_correct = 0; assert(isequal(locOf5(x),y_correct))

y = [] temp = 2 posi = [] y = 0 temp = 4 posi = [] y = 0 0 temp = 6 posi = [] y = 0 0 0 temp = 8 posi = [] y = 0 0 0 0 temp = 10 posi = [] y = 0 0 0 0 0 temp = 12 posi = [] y = 0 0 0 0 0 0 temp = 14 posi = [] y = 0 0 0 0 0 0 0 temp = 16 posi = [] y = 0 0 0 0 0 0 0 0 temp = 18 posi = [] y = 0 0 0 0 0 0 0 0 0 temp = 20 posi = [] y = 0 0 0 0 0 0 0 0 0 0 y = 0

3   Pass
x = rot90(1:10); y_correct = 6; assert(isequal(locOf5(x),y_correct))

y = [] temp = 10 9 8 7 6 5 4 3 2 1 posi = 6 y = 6

4   Pass
x = [1 2 5 5 9 1 5 6 5]; y_correct = [2 0 1]; assert(isequal(locOf5(x),y_correct))

y = [] temp = 1 5 5 posi = 2 3 y = 2 temp = 2 9 6 posi = 0×1 empty double column vector y = 2 0 temp = 5 1 5 posi = 1 3 y = 2 0 1

5   Pass
x = magic(5); y_correct = [0 2 0 0 0]; assert(isequal(locOf5(x),y_correct))

y = [] temp = 17 23 4 10 11 posi = 0×1 empty double column vector y = 0 temp = 24 5 6 12 18 posi = 2 y = 0 2 temp = 1 7 13 19 25 posi = 0×1 empty double column vector y = 0 2 0 temp = 8 14 20 21 2 posi = 0×1 empty double column vector y = 0 2 0 0 temp = 15 16 22 3 9 posi = 0×1 empty double column vector y = 0 2 0 0 0

6   Pass
x = [1 2 3 4 5; 5 4 3 2 1 2 3 5 2 1 1 5 2 6 8 3 5 2 2 5]; y_correct = [2 4 3 0 1]; assert(isequal(locOf5(x),y_correct)) % %% % x = randi([-10,10],20,1e6); % x(x==5) = 0; % p = sort(randi([0 size(x,1)],5,size(x,2))); % y_correct = p(1,:); % p(2:end,~y_correct) = 0; % [~,col,v] = find(p); % x((col-1)*size(x,1)+v) = 5; % assert(isequal(locOf5(x),y_correct))

y = [] temp = 1 5 2 1 3 posi = 2 y = 2 temp = 2 4 3 5 5 posi = 4 5 y = 2 4 temp = 3 3 5 2 2 posi = 3 y = 2 4 3 temp = 4 2 2 6 2 posi = 0×1 empty double column vector y = 2 4 3 0 temp = 5 1 1 8 5 posi = 1 5 y = 2 4 3 0 1