Cody

Solution 1394392

Submitted on 26 Dec 2017 by baruch braude
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))

n = 5 m = 5 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 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)))

n = 3 m = 4 v = 1 1 1 1 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)))

n = 10 m = 7 v = 1 1 1 1 1 1 1 v = 1 5 3 5 4 1 2 v = 2 20 3 25 20 3 4 v = 4 100 9 100 40 9 4 v = 4 300 18 300 160 45 20 v = 20 600 54 1500 160 45 40 v = 40 2400 162 1500 160 135 160 v = 160 2400 486 1500 800 270 800 v = 480 2400 1944 7500 1600 1350 800 v = 480 9600 3888 22500 8000 6750 2400 v = 960 9600 15552 67500 16000 20250 12000