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 1834554

Submitted on 2 Jun 2019 by Alisa Proekt
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))

v = [] y = 1 y = 8 y = 64 y = 640 y = 4480 v = 4480 y = 1 y = 10 y = 30 y = 120 y = 120 v = 4480 120 y = 1 y = 9 y = 18 y = 108 y = 648 v = 4480 120 648 y = 1 y = 9 y = 36 y = 72 y = 288 v = 4480 120 648 288 y = 1 y = 1 y = 4 y = 28 y = 28 v = 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))

v = [] y = 1 y = 7 y = 7 y = 42 y = 42 v = 42 y = 1 y = 4 y = 24 y = 168 y = 336 v = 42 336 y = 1 y = 1 y = 6 y = 54 y = 432 v = 42 336 432 y = 1 y = 4 y = 24 y = 192 y = 1728 v = 42 336 432 1728 y = 1 y = 5 y = 45 y = 180 y = 540 v = 42 336 432 1728 540 y = 1 y = 3 y = 24 y = 216 y = 1080 v = 42 336 432 1728 540 1080 y = 1 y = 7 y = 14 y = 84 y = 420 v = 42 336 432 1728 540 1080 420 y = 1 y = 5 y = 10 y = 70 y = 490 v = 42 336 432 1728 540 1080 420 490 y = 1 y = 7 y = 56 y = 280 y = 2520 v = 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')