Cody

Solution 2069040

Submitted on 25 Dec 2019 by victor sayegh
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 = 0 0 0 0 0 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 1 d = 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 = 0 0 0 0 d = 1 d = 1 d = 5 d = 10 d = 1 d = 2 d = 12 d = 36 d = 1 d = 3 d = 21 d = 84 d = 1 d = 4 d = 8 d = 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 = 0 0 0 0 0 0 d = 1 d = 3 d = 15 d = 30 d = 30 d = 30 d = 1 d = 5 d = 20 d = 60 d = 120 d = 360 d = 1 d = 5 d = 25 d = 50 d = 50 d = 250 d = 1 d = 4 d = 20 d = 60 d = 240 d = 720 d = 1 d = 4 d = 20 d = 100 d = 300 d = 1500 d = 1 d = 2 d = 10 d = 50 d = 100 d = 400

Suggested Problems

More from this Author25