Cody

Solution 1544953

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 = 2 x = 2 x = 8 x = 16 x = 80 x = 320 x = 320 x = 320 x = 1600 x = 1600 x = 1600 x = 1600 x = 1600 v = 1600 x = 3 x = 15 x = 75 x = 225 x = 900 x = 4500 x = 13500 x = 13500 x = 40500 x = 162000 x = 648000 x = 2592000 x = 5184000 v = 1600 5184000 x = 3 x = 9 x = 18 x = 90 x = 450 x = 900 x = 4500 x = 13500 x = 40500 x = 162000 x = 486000 x = 972000 x = 972000 v = 1600 5184000 972000 x = 1 x = 3 x = 9 x = 36 x = 72 x = 360 x = 1800 x = 5400 x = 16200 x = 48600 x = 48600 x = 243000 x = 729000 v = 1600 5184000 972000 729000 x = 5 x = 25 x = 25 x = 75 x = 375 x = 1500 x = 4500 x = 22500 x = 22500 x = 90000 x = 270000 x = 1350000 x = 6750000 v = 1600 5184000 972000 729000 6750000 x = 5 x = 15 x = 15 x = 75 x = 150 x = 300 x = 300 x = 900 x = 3600 x = 14400 x = 57600 x = 115200 x = 230400 v = 1600 5184000 972000 729000 6750000 230400 x = 3 x = 15 x = 45 x = 180 x = 360 x = 1080 x = 5400 x = 5400 x = 21600 x = 43200 x = 129600 x = 518400 x = 2592000 v = 1600 5184000 972000 729000 6750000 230400 2592000 x = 1 x = 2 x = 10 x = 10 x = 10 x = 10 x = 30 x = 120 x = 240 x = 720 x = 2880 x = 14400 x = 14400 v = 1600 5184000 972000 729000 6750000 230400 2592000 14400 x = 2 x = 4 x = 20 x = 20 x = 80 x = 240 x = 240 x = 720 x = 2160 x = 4320 x = 12960 x = 25920 x = 129600 v = 1600 5184000 972000 729000 6750000 230400 2592000 14400 129600 x = 3 x = 3 x = 9 x = 27 x = 54 x = 162 x = 648 x = 2592 x = 10368 x = 31104 x = 62208 x = 186624 x = 559872 v = 1600 5184000 972000 729000 6750000 230400 2592000 14400 129600 559872 x = 3 x = 12 x = 24 x = 96 x = 288 x = 864 x = 1728 x = 8640 x = 17280 x = 86400 x = 432000 x = 2160000 x = 10800000 v = 1600 5184000 972000 729000 6750000 230400 2592000 14400 129600 559872 10800000 x = 5 x = 25 x = 100 x = 400 x = 1200 x = 4800 x = 14400 x = 28800 x = 115200 x = 230400 x = 460800 x = 1843200 x = 5529600 v = 1600 5184000 972000 729000 6750000 230400 2592000 14400 129600 559872 10800000 5529600 x = 1 x = 5 x = 10 x = 40 x = 160 x = 480 x = 1920 x = 3840 x = 19200 x = 19200 x = 96000 x = 96000 x = 288000 v = 1600 5184000 972000 729000 6750000 230400 2592000 14400 129600 559872 10800000 5529600 288000