Cody

# Problem 44467. Product of Each Column

Solution 2608597

Submitted on 24 Jun 2020 by Othman Salih
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))

m = 5 n = 5 v = 1 1 1 1 1 x = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 x = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 x = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 x = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 x = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 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)))

m = 3 n = 4 v = 1 1 1 1 x = 1 5 2 v = 1 1 1 1 v = 5 1 1 1 v = 10 1 1 1 x = 2 6 3 v = 10 2 1 1 v = 10 12 1 1 v = 10 36 1 1 x = 3 7 4 v = 10 36 3 1 v = 10 36 21 1 v = 10 36 84 1 x = 4 2 5 v = 10 36 84 4 v = 10 36 84 8 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)))

m = 5 n = 5 v = 1 1 1 1 1 x = 2 1 2 1 1 v = 2 1 1 1 1 v = 2 1 1 1 1 v = 4 1 1 1 1 v = 4 1 1 1 1 v = 4 1 1 1 1 x = 3 2 5 1 5 v = 4 3 1 1 1 v = 4 6 1 1 1 v = 4 30 1 1 1 v = 4 30 1 1 1 v = 4 150 1 1 1 x = 2 2 5 5 3 v = 4 150 2 1 1 v = 4 150 4 1 1 v = 4 150 20 1 1 v = 4 150 100 1 1 v = 4 150 300 1 1 x = 5 2 2 3 5 v = 4 150 300 5 1 v = 4 150 300 10 1 v = 4 150 300 20 1 v = 4 150 300 60 1 v = 4 150 300 300 1 x = 4 1 2 2 5 v = 4 150 300 300 4 v = 4 150 300 300 4 v = 4 150 300 300 8 v = 4 150 300 300 16 v = 4 150 300 300 80

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!