Cody

Solution 1544946

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

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 = 1 x = 1 x = 4 x = 16 x = 80 x = 160 x = 160 x = 160 x = 640 x = 3200 x = 9600 x = 38400 x = 115200 x = 230400 v = 230400 x = 1 x = 5 x = 20 x = 60 x = 120 x = 480 x = 480 x = 960 x = 960 x = 1920 x = 5760 x = 28800 x = 144000 x = 720000 x = 720000 v = 230400 720000 x = 1 x = 3 x = 3 x = 9 x = 45 x = 225 x = 450 x = 1350 x = 6750 x = 13500 x = 27000 x = 54000 x = 162000 x = 324000 x = 648000 v = 230400 720000 648000 x = 1 x = 2 x = 6 x = 18 x = 18 x = 90 x = 180 x = 180 x = 900 x = 1800 x = 3600 x = 14400 x = 72000 x = 216000 x = 216000 v = 230400 720000 648000 216000 x = 1 x = 1 x = 5 x = 25 x = 100 x = 100 x = 200 x = 600 x = 2400 x = 7200 x = 7200 x = 21600 x = 64800 x = 64800 x = 129600 v = 230400 720000 648000 216000 129600 x = 1 x = 2 x = 4 x = 12 x = 48 x = 96 x = 480 x = 2400 x = 2400 x = 2400 x = 12000 x = 12000 x = 48000 x = 192000 x = 768000 v = 230400 720000 648000 216000 129600 768000 x = 1 x = 1 x = 1 x = 2 x = 4 x = 8 x = 40 x = 200 x = 200 x = 800 x = 3200 x = 6400 x = 25600 x = 128000 x = 256000 v = 230400 720000 648000 216000 129600 768000 256000 x = 1 x = 2 x = 8 x = 8 x = 24 x = 48 x = 240 x = 960 x = 2880 x = 14400 x = 43200 x = 86400 x = 259200 x = 777600 x = 2332800 v = 230400 720000 648000 216000 129600 768000 256000 2332800 x = 1 x = 2 x = 8 x = 32 x = 32 x = 160 x = 160 x = 640 x = 2560 x = 5120 x = 15360 x = 46080 x = 92160 x = 368640 x = 1474560 v = 230400 720000 648000 216000 129600 768000 256000 2332800 1474560 x = 1 x = 3 x = 9 x = 18 x = 90 x = 90 x = 360 x = 720 x = 2880 x = 2880 x = 8640 x = 17280 x = 34560 x = 138240 x = 276480 v = 230400 720000 648000 216000 129600 768000 256000 2332800 1474560 276480 x = 1