Cody

# Problem 44467. Product of Each Column

Solution 2073595

Submitted on 29 Dec 2019 by Shlomi Shomonov
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))

w = 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 w = 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 w = 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 w = 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 w = 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)))

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

w = 5 2 5 2 5 1 4 5 3 v = 5 1 1 1 1 1 v = 10 1 1 1 1 1 v = 50 1 1 1 1 1 v = 100 1 1 1 1 1 v = 500 1 1 1 1 1 v = 500 1 1 1 1 1 v = 2000 1 1 1 1 1 v = 10000 1 1 1 1 1 v = 30000 1 1 1 1 1 w = 4 4 2 4 3 4 5 2 5 v = 30000 4 1 1 1 1 v = 30000 16 1 1 1 1 v = 30000 32 1 1 1 1 v = 30000 128 1 1 1 1 v = 30000 384 1 1 1 1 v = 30000 1536 1 1 1 1 v = 30000 7680 1 1 1 1 v = 30000 15360 1 1 1 1 v = 30000 76800 1 1 1 1 w = 5 4 4 1 4 2 5 4 5 v = 30000 76800 5 1 1 1 v = 30000 76800 20 1 1 1 v = 30000 76800 80 1 1 1 v = 30000 76800 80 1 1 1 v = 30000 76800 320 1 1 1 v = 30000 76800 640 1 1 1 v = 30000 76800 3200 1 1 1 v = 30000 76800 12800 1 1 1 v = 30000 76800 64000 1 1 1 w = 5 4 5 3 2 1 3 5 4 v = 30000 76800 64000 5 1 1 v = 30000 76800 64000 20 1 1 v = 30000 76800 64000 100 1 1 v = 30000 76800 64000 300 1 1 v = 30000 76800 64000 600 1 1 v = 30000 76800 64000 600 1 1 v = 30000 76800 64000 1800 1 1 v = 30000 76800 64000 9000 1 1 v = 30000 76800 64000 36000 1 1 w = 4 4 2 2 4 3 3 3 2 v = 30000 76800 64000 36000 4 1 v = 30000 76800 64000 36000 16 1 v = 30000 76800 64000 36000 32 1 v = 30000 76800 64000 36000 64 1 v = 30000 76800 64000 36000 256 1 v = 30000 76800 64000 36000 768 1 v = 30000 76800 64000 36000 2304 1 v = 30000 76800 64000 36000 6912 1 v = 30000 76800 64000 36000 13824 1 w = 3 4 5 5 4 1 3 3 4 v = 30000 76800 64000 36000 13824 3 v = 30000 76800 64000 36000 13824 12 v = 30000 76800 64000 36000 13824 60 v = 30000 76800 64000 36000 13824 300 v = 30000 76800 64000 36000 13824 1200 v = 30000 76800 64000 36000 13824 1200 v = 30000 76800 64000 36000 13824 3600 v = 30000 76800 64000 36000 13824 10800 v = 30000 76800 64000 36000 13824 43200

### Community Treasure Hunt

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

Start Hunting!