Cody

Solution 2070802

Submitted on 27 Dec 2019 by Avishay Hertz
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))

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

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

m = 12 n = 8 v = 1 1 1 1 1 1 1 1 v = 4 4 2 1 3 1 3 2 v = 8 4 2 1 9 4 15 2 v = 32 20 4 3 36 20 60 4 v = 128 60 16 6 72 20 60 12 v = 256 240 64 6 360 40 180 36 v = 1024 240 192 30 1800 200 540 108 v = 4096 1200 192 60 1800 400 1080 540 v = 8192 6000 576 240 9000 800 4320 1620 v = 8192 18000 1152 720 36000 4000 17280 1620 v = 16384 72000 3456 3600 36000 16000 51840 1620 v = 65536 216000 17280 18000 144000 32000 103680 4860 v = 196608 864000 86400 72000 576000 160000 103680 14580