Cody

# Problem 44467. Product of Each Column

Solution 1705647

Submitted on 10 Jan 2019 by Martin C.
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))

v = [] p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 v = 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 v = 1 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 v = 1 1 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 v = 1 1 1 1 p = 1 p = 1 p = 1 p = 1 p = 1 p = 1 v = 1 1 1 1 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)))

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

v = [] p = 1 p = 1 p = 5 p = 25 p = 100 p = 200 p = 200 p = 200 p = 1000 p = 1000 p = 4000 p = 12000 v = 12000 p = 1 p = 1 p = 5 p = 25 p = 25 p = 25 p = 125 p = 250 p = 1250 p = 3750 p = 11250 p = 22500 v = 12000 22500 p = 1 p = 2 p = 10 p = 30 p = 120 p = 480 p = 1440 p = 2880 p = 5760 p = 23040 p = 115200 p = 460800 v = 12000 22500 460800 p = 1 p = 1 p = 1 p = 2 p = 2 p = 6 p = 18 p = 18 p = 36 p = 180 p = 180 p = 900 v = 12000 22500 460800 900 p = 1 p = 5 p = 5 p = 10 p = 20 p = 60 p = 60 p = 120 p = 120 p = 480 p = 1920 p = 5760 v = 12000 22500 460800 900 5760 v = 12000 22500 460800 900 5760