Cody

Solution 2032259

Submitted on 22 Nov 2019 by Asif Newaz
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))

a = 5 b = 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 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 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 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 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)))

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

a = 13 b = 8 v = 1 1 1 1 1 1 1 1 v = 2 1 1 1 1 1 1 1 v = 10 1 1 1 1 1 1 1 v = 50 1 1 1 1 1 1 1 v = 250 1 1 1 1 1 1 1 v = 250 1 1 1 1 1 1 1 v = 750 1 1 1 1 1 1 1 v = 3000 1 1 1 1 1 1 1 v = 12000 1 1 1 1 1 1 1 v = 12000 1 1 1 1 1 1 1 v = 48000 1 1 1 1 1 1 1 v = 96000 1 1 1 1 1 1 1 v = 384000 1 1 1 1 1 1 1 v = 1536000 1 1 1 1 1 1 1 v = 1536000 4 1 1 1 1 1 1 v = 1536000 20 1 1 1 1 1 1 v = 1536000 100 1 1 1 1 1 1 v = 1536000 500 1 1 1 1 1 1 v = 1536000 1500 1 1 1 1 1 1 v = 1536000 1500 1 1 1 1 1 1 v = 1536000 7500 1 1 1 1 1 1 v = 1536000 7500 1 1 1 1 1 1 v = 1536000 22500 1 1 1 1 1 1 v = 1536000 67500 1 1 1 1 1 1 v = 1536000 270000 1 1 1 1 1 1 v = 1536000 810000 1 1 1 1 1 1 v = 1536000 810000 1 1 1 1 1 1 v = 1536000 810000 2 1 1 1 1 1 v = 1536000 810000 10 1 1 1 1 1 v = 1536000 810000 50 1 1 1 1 1 v = 1536000 810000 100 1 1 1 1 1 v = 1536000 810000 500 1 1 1 1 1 v = 1536000 810000 1000 1 1 1 1 1 v = 1536000 810000 1000 1 1 1 1 1 v = 1536000 810000 1000 1 1 1 1 1 v = 1536000 810000 2000 1 1 1 1 1 v = 1536000 810000 10000 1 1 1 1 1 v = 1536000 810000 10000 1 1 1 1 1 v = 1536000 810000 50000 1 1 1 1 1 v = 1536000 810000 250000 1 1 1 1 1 v = 1536000 810000 250000 2 1 1 1 1 v = 1536000 810000 250000 10 1 1 1 1 v = 1536000 810000 250000 40 1 1 1 1 v = 1536000 810000 250000 80 1 1 1 1 v = 1536000 810000 250000 160 1 1 1 1 v = 1536000 810000 250000 480 1 1 1 1 v = 1536000 810000 250000 960 1 1 1 1 v = 1536000 810000 250000 960 1 1 1 1 v = 1536000 810000 250000 960 1 1 1 1 v = 1536000 810000 250000 4800 1 1 1 1 v = 1536000 810000 250000 19200 1 1 1 1 v = 1536000 810000 250000 76800 1 1 1 1 v = 1536000 810000 250000 384000 1 1 1 1 v = 1536000 810000 250000 384000 3 1 1 1 v = 1536000 810000 250000 384000 6 1 1 1 v = 1536000 810000 250000 384000 12 1 1 1 v = 1536000 810000 250000 384000 12 1 1 1 v = 1536000 810000 250000 384000 12 1 1 1 v = 1536000 810000 250000 384000 48 1 1 1 v = 1536000 810000 250000 384000 144 1 1 1 v = 1536000 810000 250000 384000 432 1 1 1 v = 1536000 810000 250000 384000 1296 1 1 1 v = 1536000 810000 250000 384000 3888 1 1 1 v = 1536000 810000 250000 384000 15552 1 1 1 v = 1536000 810000 250000 384000 15552 1 1 1 v = 1536000 810000 250000 384000 15552 1 1 1 v = 1536000 810000 250000 384000 15552 3 1 1 v = 1536000 810000 250000 384000 15552 15 1 1 v = 1536000 810000 250000 384000 15552 15 1 1 v = 1536000 810000 250000 384000 15552 30 1 1 v = 1536000 810000 250000 384000 15552 60 1 1 v = 1536000 810000 250000 384000 15552 120 1 1 v = 1536000 810000 250000 384000 15552 600 1 1 v = 1536000 810000 250000 384000 15552 1200 1 1 v = 1536000 810000 250000 384000 15552 1200 1 1 v = 1536000 810000 250000 384000 15552 3600 1 1 v = 1536000 810000 250000 384000 15552 7200 1 1 v = 1536000 810000 250000 384000 15552 21600 1 1 v = 1536000 810000 250000 384000 15552 21600 1 1 v = 1536000 810000 250000 384000 15552 21600 5 1 v = 1536000 810000 250000 384000 15552 21600 15 1 v = 1536000 810000 250000 384000 15552 21600 60 1 v = 1536000 810000 250000 384000 15552 21600 240 1 v = 1536000 810000 250000 384000 15552 21600 480 1 v = 1536000 810000 250000 384000 15552 21600 480 1 v = 1536000 810000 250000 384000 15552 21600 1440 1 v = 1536000 810000 250000 384000 15552 21600 5760 1 v = 1536000 810000 250000 384000 15552 21600 28800 1 v = 1536000 810000 250000 384000 15552 21600 144000 1 v = 1536000 810000 250000 384000 15552 21600 288000 1 v = 1536000 810000 250000 384000 15552 21600 864000 1 v = 1536000 810000 250000 384000 15552 21600 2592000 1 v = 1536000 810000 250000 384000 15552 21600 2592000 2 v = 1536000 810000 250000 384000 15552 21600 2592000 2 v = 1536000 810000 250000 384000 15552 21600 2592000 6 v = 1536000 810000 250000 384000 15552 21600 2592000 30 v = 1536000 810000 250000 384000 15552 21600 2592000 60 v = 1536000 810000 250000 384000 15552 21600 2592000 60 v = 1536000 810000 250000 384000 15552 21600 2592000 120 v = 15...

Suggested Problems

More from this Author25