Cody

Solution 1544951

Submitted on 31 May 2018 by avi kiko
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))

x = 1 x = 1 x = 1 x = 1 x = 1 v = 1 x = 1 x = 1 x = 1 x = 1 x = 1 v = 1 1 x = 1 x = 1 x = 1 x = 1 x = 1 v = 1 1 1 x = 1 x = 1 x = 1 x = 1 x = 1 v = 1 1 1 1 x = 1 x = 1 x = 1 x = 1 x = 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)))

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

x = 4 x = 4 x = 12 x = 36 x = 108 x = 324 x = 648 x = 1296 x = 5184 x = 10368 x = 20736 v = 20736 x = 1 x = 4 x = 20 x = 100 x = 200 x = 600 x = 1200 x = 1200 x = 1200 x = 4800 x = 19200 v = 20736 19200 x = 2 x = 4 x = 12 x = 24 x = 120 x = 480 x = 1440 x = 7200 x = 21600 x = 86400 x = 259200 v = 20736 19200 259200 x = 1 x = 2 x = 6 x = 18 x = 72 x = 360 x = 720 x = 720 x = 3600 x = 18000 x = 72000 v = 20736 19200 259200 72000 x = 1 x = 5 x = 15 x = 45 x = 135 x = 675 x = 2025 x = 6075 x = 12150 x = 24300 x = 48600 v = 20736 19200 259200 72000 48600 x = 3 x = 9 x = 36 x = 180 x = 360 x = 1440 x = 7200 x = 7200 x = 36000 x = 108000 x = 216000 v = 20736 19200 259200 72000 48600 216000 x = 1 x = 3 x = 6 x = 30 x = 90 x = 90 x = 90 x = 90 x = 180 x = 900 x = 900 v = 20736 19200 259200 72000 48600 216000 900