Cody

# Problem 44467. Product of Each Column

Solution 2067550

Submitted on 23 Dec 2019 by Arif Gasimov
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))

P = 1 P = 1 P = 1 P = 1 P = 1 P = 1 v = 1 0 0 0 0 P = 1 P = 1 P = 1 P = 1 P = 1 P = 1 v = 1 1 0 0 0 P = 1 P = 1 P = 1 P = 1 P = 1 P = 1 v = 1 1 1 0 0 P = 1 P = 1 P = 1 P = 1 P = 1 P = 1 v = 1 1 1 1 0 P = 1 P = 1 P = 1 P = 1 P = 1 P = 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)))

P = 1 P = 1 P = 5 P = 10 v = 10 0 0 0 P = 1 P = 2 P = 12 P = 36 v = 10 36 0 0 P = 1 P = 3 P = 21 P = 84 v = 10 36 84 0 P = 1 P = 4 P = 8 P = 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)))

P = 1 P = 4 P = 20 P = 80 P = 240 P = 720 P = 2880 P = 14400 v = 14400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 P = 1 P = 3 P = 3 P = 12 P = 12 P = 36 P = 36 P = 144 v = 14400 144 0 0 0 0 0 0 0 0 0 0 0 0 0 P = 1 P = 5 P = 25 P = 125 P = 625 P = 2500 P = 2500 P = 10000 v = 14400 144 10000 0 0 0 0 0 0 0 0 0 0 0 0 P = 1 P = 2 P = 6 P = 12 P = 60 P = 60 P = 180 P = 180 v = 14400 144 10000 180 0 0 0 0 0 0 0 0 0 0 0 P = 1 P = 2 P = 2 P = 4 P = 8 P = 16 P = 16 P = 32 v = 14400 144 10000 180 32 0 0 0 0 0 0 0 0 0 0 P = 1 P = 1 P = 2 P = 2 P = 10 P = 40 P = 80 P = 240 v = 14400 144 10000 180 32 240 0 0 0 0 0 0 0 0 0 P = 1 P = 3 P = 9 P = 45 P = 135 P = 540 P = 2160 P = 4320 v = 14400 144 10000 180 32 240 4320 0 0 0 0 0 0 0 0 P = 1 P = 2 P = 4 P = 8 P = 8 P = 32 P = 96 P = 480 v = 14400 144 10000 180 32 240 4320 480 0 0 0 0 0 0 0 P = 1 P = 1 P = 1 P = 5 P = 25 P = 125 P = 250 P = 250 v = 14400 144 10000 180 32 240 4320 480 250 0 0 0 0 0 0 P = 1 P = 2 P = 2 P = 2 P = 2 P = 8 P = 16 P = 64 v = 14400 144 10000 180 32 240 4320 480 250 64 0 0 0 0 0 P = 1 P = 1 P = 2 P = 4 P = 12 P = 12 P = 48 P = 192 v = 14400 144 10000 180 32 240 4320 480 250 64 192 0 0 0 0 P = 1 P = 3 P = 9 P = 18 P = 18 P = 36 P = 144 P = 144 v = 14400 144 10000 180 32 240 4320 480 250 64 192 144 0 0 0 P = 1 P = 4 P = 8 P = 24 P = 24 P = 24 P = 120 P = 120 v = 14400 144 10000 180 32 240 4320 480 250 64 192 144 120 0 0 P = 1 P = 3 P = 12 P = 24 P = 72 P = 144 P = 432 P = 1296 v = 14400 144 10000 180 32 240 4320 480 250 64 192 144 120 1296 0 P = 1 P = 1 P = 1 P = 2 P = 8 P = 24 P = 48 P = 192 v = 14400 144 10000 180 32 240 4320 480 250 64 192 144 120 1296 192