Cody

Solution 1548445

Submitted on 4 Jun 2018 by tamir zinger
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 = 0 0 0 0 0 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 0 0 0 0 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 0 0 0 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 0 0 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 0 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 1 1 1 1 1 mat = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 = 0 0 0 mat = 1 2 3 4 5 6 7 2 2 3 4 5 v = 5 0 0 mat = 1 2 3 4 5 12 7 2 2 3 4 5 v = 5 12 0 mat = 1 2 3 4 5 12 21 2 2 3 4 5 v = 5 12 21 mat = 1 2 3 4 5 12 21 8 2 3 4 5 v = 5 12 21 8 mat = 1 2 3 4 5 12 21 8 10 3 4 5 v = 10 12 21 8 mat = 1 2 3 4 5 12 21 8 10 36 4 5 v = 10 36 21 8 mat = 1 2 3 4 5 12 21 8 10 36 84 5 v = 10 36 84 8 mat = 1 2 3 4 5 12 21 8 10 36 84 40 v = 10 36 84 40

5   Pass
m = randi([5,15]); n = randi([5,15]); mat = rand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 1 3 5 1 1 1 2 v = 25 12 8 8 20 3 20 3 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 4 3 4 5 2 1 5 4 5 1 5 4 3 1 1 3 5 1 1 1 2 v = 25 12 40 8 20 3 20 3 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 3 4 5 2 1 5 4 5 1 5 4 3 1 1 3 5 1 1 1 2 v = 25 12 40 32 20 3 20 3 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 4 5 2 1 5 4 5 1 5 4 3 1 1 3 5 1 1 1 2 v = 25 12 40 32 60 3 20 3 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 5 2 1 5 4 5 1 5 4 3 1 1 3 5 1 1 1 2 v = 25 12 40 32 60 12 20 3 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 2 1 5 4 5 1 5 4 3 1 1 3 5 1 1 1 2 v = 25 12 40 32 60 12 100 3 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 1 5 4 5 1 5 4 3 1 1 3 5 1 1 1 2 v = 25 12 40 32 60 12 100 6 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 5 4 5 1 5 4 3 1 1 3 5 1 1 1 2 v = 25 12 40 32 60 12 100 6 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 4 5 1 5 4 3 1 1 3 5 1 1 1 2 v = 25 60 40 32 60 12 100 6 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 5 1 5 4 3 1 1 3 5 1 1 1 2 v = 25 60 160 32 60 12 100 6 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 1 5 4 3 1 1 3 5 1 1 1 2 v = 25 60 160 160 60 12 100 6 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 5 4 3 1 1 3 5 1 1 1 2 v = 25 60 160 160 60 12 100 6 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 60 4 3 1 1 3 5 1 1 1 2 v = 25 60 160 160 60 60 100 6 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 60 400 3 1 1 3 5 1 1 1 2 v = 25 60 160 160 60 60 400 6 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 60 400 18 1 1 3 5 1 1 1 2 v = 25 60 160 160 60 60 400 18 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 60 400 18 25 1 3 5 1 1 1 2 v = 25 60 160 160 60 60 400 18 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 60 400 18 25 60 3 5 1 1 1 2 v = 25 60 160 160 60 60 400 18 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 60 400 18 25 60 480 5 1 1 1 2 v = 25 60 480 160 60 60 400 18 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 60 400 18 25 60 480 800 1 1 1 2 v = 25 60 480 800 60 60 400 18 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 60 400 18 25 60 480 800 60 1 1 2 v = 25 60 480 800 60 60 400 18 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 60 400 18 25 60 480 800 60 60 1 2 v = 25 60 480 800 60 60 400 18 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 60 400 18 25 60 480 800 60 60 400 2 v = 25 60 480 800 60 60 400 18 mat = 1 1 2 4 5 3 4 1 5 4 8 8 20 3 20 3 25 12 40 32 60 12 100 6 25 60 160 160 60 60 400 18 25 60 480 800 60 60 400 36 v = 25 60 480 800 60 60 400 36