Cody

# Problem 44889. Given a matrix A return a vector of the product of the elements in each column using a loop without using prod.

Solution 2032710

Submitted on 23 Nov 2019 by ABHILASH SINGH
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
x = [8 10 9 9 1 8 3 2 4 4 10 4 6 2 7 7 1 6 4 1]; y_correct = [4480 120 648 288 28]; assert(isequal(ProdMat(x),y_correct))

r = 4 c = 5 v = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 8 10 9 9 1 8 10 9 9 1 8 10 9 9 1 8 10 9 9 1 v = 64 30 18 36 4 64 30 18 36 4 64 30 18 36 4 64 30 18 36 4 v = 640 120 108 72 28 640 120 108 72 28 640 120 108 72 28 640 120 108 72 28 v = 4480 120 648 288 28 4480 120 648 288 28 4480 120 648 288 28 4480 120 648 288 28

2   Pass
x = [7 4 1 4 5 3 7 5 7 1 6 6 6 9 8 2 2 8 6 7 9 8 4 9 6 7 5 1 2 8 9 3 5 5 7 9]; y_correct = [42 336 432 1728 540 1080 420 490 2520]; assert(isequal(ProdMat(x),y_correct))

r = 4 c = 9 v = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 v = 7 4 1 4 5 3 7 5 7 7 4 1 4 5 3 7 5 7 7 4 1 4 5 3 7 5 7 7 4 1 4 5 3 7 5 7 v = 7 24 6 24 45 24 14 10 56 7 24 6 24 45 24 14 10 56 7 24 6 24 45 24 14 10 56 7 24 6 24 45 24 14 10 56 v = 42 168 54 192 180 216 84 70 280 42 168 54 192 180 216 84 70 280 42 168 54 192 180 216 84 70 280 42 168 54 192 180 216 84 70 280 v = 42 336 432 1728 540 1080 420 490 2520 42 336 432 1728 540 1080 420 490 2520 42 336 432 1728 540 1080 420 490 2520 42 336 432 1728 540 1080 420 490 2520

3   Pass
filetext = fileread('ProdMat.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

4   Pass
filetext = fileread('ProdMat.m'); assert(isempty(strfind(filetext, 'prod')),'prod() function is forbidden')

5   Pass
filetext = fileread('ProdMat.m'); assert(isempty(strfind(filetext, '!echo')),'!echo hacks are forbidden')