Cody

Solution 2510567

Submitted on 10 Jun 2020 by jony hait
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('myProd.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Pass
filetext = fileread('myProd.m'); assert(isempty(strfind(filetext, 'prod')),'Cannot use prod() function')

3   Pass
mat = ones(5); v_correct = ones(1, 5); assert(isequal(myProd(mat),v_correct))

v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1

4   Pass
mat = [ 1, 2, 3, 4; 5, 6, 7, 2; 2, 3, 4, 5]; v_correct = [10, 36, 84, 40]; assert(isequal(myProd(mat),prod(mat)))

v = 1 2 3 4 v = 5 12 21 8 v = 10 36 84 40

5   Pass
m = randi([5,15]); n = randi([5,15]); mat = randi(5, n, m); v_correct = prod(mat); assert(isequal(myProd(mat),prod(mat)))

v = 4 3 4 4 5 3 5 3 1 3 5 v = 8 3 16 12 25 3 10 9 5 15 20 v = 24 3 64 48 25 9 10 18 10 60 40 v = 96 12 320 144 75 27 40 90 20 240 40 v = 384 12 1600 144 150 108 120 270 80 240 200 v = 768 48 8000 720 300 324 120 540 160 960 200 v = 3072 48 40000 1440 900 972 120 1620 320 1920 200