Cody

Solution 1399530

Submitted on 31 Dec 2017 by nadav regev
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))

p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 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)))

p = 1 p = 5 p = 10 p = 2 p = 12 p = 36 p = 3 p = 21 p = 84 p = 4 p = 8 p = 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)))

p = 2 p = 2 p = 2 p = 2 p = 2 p = 2 p = 4 p = 4 p = 20 p = 3 p = 15 p = 30 p = 120 p = 360 p = 1800 p = 1800 p = 7200 p = 36000 p = 5 p = 25 p = 50 p = 50 p = 100 p = 400 p = 2000 p = 4000 p = 12000 p = 5 p = 15 p = 75 p = 75 p = 300 p = 600 p = 600 p = 1800 p = 7200 p = 4 p = 16 p = 16 p = 48 p = 144 p = 576 p = 2304 p = 11520 p = 34560 p = 3 p = 6 p = 18 p = 90 p = 450 p = 450 p = 450 p = 2250 p = 2250 p = 1 p = 1 p = 4 p = 8 p = 32 p = 32 p = 128 p = 512 p = 1536 p = 4 p = 16 p = 32 p = 160 p = 320 p = 640 p = 1920 p = 7680 p = 23040 p = 4 p = 12 p = 48 p = 144 p = 432 p = 1728 p = 6912 p = 6912 p = 13824