Cody

# Problem 44467. Product of Each Column

Solution 1517826

Submitted on 5 May 2018 by Jacob Lavzin
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))

r = 5 c = 5 k = 1 w = 1 1 1 1 1 k = 1 k = 1 k = 1 k = 1 k = 1 v = 1 k = 1 w = 1 1 1 1 1 k = 1 k = 1 k = 1 k = 1 k = 1 v = 1 1 k = 1 w = 1 1 1 1 1 k = 1 k = 1 k = 1 k = 1 k = 1 v = 1 1 1 k = 1 w = 1 1 1 1 1 k = 1 k = 1 k = 1 k = 1 k = 1 v = 1 1 1 1 k = 1 w = 1 1 1 1 1 k = 1 k = 1 k = 1 k = 1 k = 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)))

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

r = 14 c = 10 k = 1 w = 4 3 4 1 4 4 2 5 2 4 2 1 1 4 k = 4 k = 12 k = 48 k = 48 k = 192 k = 768 k = 1536 k = 7680 k = 15360 k = 61440 k = 122880 k = 122880 k = 122880 k = 491520 v = 491520 k = 1 w = 1 5 1 1 5 4 4 2 4 3 5 5 3 2 k = 1 k = 5 k = 5 k = 5 k = 25 k = 100 k = 400 k = 800 k = 3200 k = 9600 k = 48000 k = 240000 k = 720000 k = 1440000 v = 491520 1440000 k = 1 w = 2 5 1 1 5 2 2 2 2 3 4 5 1 1 k = 2 k = 10 k = 10 k = 10 k = 50 k = 100 k = 200 k = 400 k = 800 k = 2400 k = 9600 k = 48000 k = 48000 k = 48000 v = 491520 1440000 48000 k = 1 w = 2 1 3 2 2 5 3 4 4 4 5 1 3 1 k = 2 k = 2 k = 6 k = 12 k = 24 k = 120 k = 360 k = 1440 k = 5760 k = 23040 k = 115200 k = 115200 k = 345600 k = 345600 v = 491520 1440000 48000 345600 k = 1 w = 4 5 1 4 2 5 2 5 4 2 1 5 3 2 k = 4 k = 20 k = 20 k = 80 k = 160 k = 800 k = 1600 k = 8000 k = 32000 k = 64000 k = 64000 k = 320000 k = 960000 k = 1920000 v = 491520 1440000 48000 345600 1920000 k = 1 w = 2 1 5 2 1 3 5 4 2 5 4 5 3 2 k = 2 k = 2 k = 10 k = 20 k = 20 k = 60 k = 300 k = 1200 k = 2400 k = 12000 k = 48000 k = 240000 k = 720000 k = 1440000 v = 491520 1440000 48000 345600 1920000 1440000 k = 1 w = 5 1 1 3 5 2 4 3 4 5 4 5 2 5 k = 5 k = 5 k = 5 k = 15 k = 75 k = 150 k = 600 k = 1800 k = 7200 k = 36000 k = 144000 k = 720000 k = 1440000 k = 7200000 v = 491520 1440000 48000 345600 1920000 1440000 7200000 k = 1 w = 4 2 5 2 1 4 1 4 5 2 5 2 4 2 k = 4 k = 8 k = 40 k = 80 k = 80 k = 320 k = 320 k = 1280 k = 6400 k = 12800 k = 64000 k = 128000 k = 512000 k = 1024000 v = 491520 1440000 48000 345600 1920000 1440000 7200000 1024000 k = 1 w = 2 4 4 4 1 1 1 5 5 2 5 5 1 3 k = 2 k = 8 k = 32 k = 128 k = 128 k = 128 k = 128 k = 640 k = 3200 k = 6400 k = 32000 k = 160000 k = 160000 k = 480000 v = 491520 1440000 48000 345600 1920000 1440000 7200000 1024000 480000 k = 1 w = 3 2 4 5 3 2 4 4 4 1 1 3 3 5 k = 3 k = 6 k = 24 k = 120 k = 360 k = 720 k = 2880 k = 11520 k = 46080 k = 46080 k = 46080 k = 138240 k = 414720 k = 2073600 v = 491520 1440000 48000 345600 1920000 1440000 7200000 1024000 480000 2073600