Cody

# Problem 44467. Product of Each Column

Solution 3387278

Submitted on 26 Oct 2020 by Ben Vien
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 = 1 v = 1 v = 1 v = 1 v = 1 v = 1 1 v = 1 1 v = 1 1 v = 1 1 v = 1 1 v = 1 1 1 v = 1 1 1 v = 1 1 1 v = 1 1 1 v = 1 1 1 v = 1 1 1 1 v = 1 1 1 1 v = 1 1 1 1 v = 1 1 1 1 v = 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)))

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

v = 5 v = 15 v = 15 v = 60 v = 240 v = 960 v = 3840 v = 15360 v = 15360 v = 46080 v = 230400 v = 230400 5 v = 230400 10 v = 230400 30 v = 230400 60 v = 230400 300 v = 230400 900 v = 230400 3600 v = 230400 7200 v = 230400 14400 v = 230400 43200 v = 230400 216000 v = 230400 216000 3 v = 230400 216000 12 v = 230400 216000 12 v = 230400 216000 60 v = 230400 216000 180 v = 230400 216000 900 v = 230400 216000 1800 v = 230400 216000 3600 v = 230400 216000 14400 v = 230400 216000 14400 v = 230400 216000 57600 v = 230400 216000 57600 3 v = 230400 216000 57600 12 v = 230400 216000 57600 60 v = 230400 216000 57600 180 v = 230400 216000 57600 900 v = 230400 216000 57600 2700 v = 230400 216000 57600 8100 v = 230400 216000 57600 32400 v = 230400 216000 57600 162000 v = 230400 216000 57600 810000 v = 230400 216000 57600 4050000 v = 230400 216000 57600 4050000 4 v = 230400 216000 57600 4050000 16 v = 230400 216000 57600 4050000 80 v = 230400 216000 57600 4050000 320 v = 230400 216000 57600 4050000 640 v = 230400 216000 57600 4050000 640 v = 230400 216000 57600 4050000 640 v = 230400 216000 57600 4050000 1280 v = 230400 216000 57600 4050000 6400 v = 230400 216000 57600 4050000 25600 v = 230400 216000 57600 4050000 128000 v = 230400 216000 57600 4050000 128000 4 v = 230400 216000 57600 4050000 128000 16 v = 230400 216000 57600 4050000 128000 80 v = 230400 216000 57600 4050000 128000 80 v = 230400 216000 57600 4050000 128000 160 v = 230400 216000 57600 4050000 128000 640 v = 230400 216000 57600 4050000 128000 1920 v = 230400 216000 57600 4050000 128000 3840 v = 230400 216000 57600 4050000 128000 15360 v = 230400 216000 57600 4050000 128000 61440 v = 230400 216000 57600 4050000 128000 184320 v = 230400 216000 57600 4050000 128000 184320 1 v = 230400 216000 57600 4050000 128000 184320 1 v = 230400 216000 57600 4050000 128000 184320 2 v = 230400 216000 57600 4050000 128000 184320 4 v = 230400 216000 57600 4050000 128000 184320 12 v = 230400 216000 57600 4050000 128000 184320 60 v = 230400 216000 57600 4050000 128000 184320 60 v = 230400 216000 57600 4050000 128000 184320 60 v = 230400 216000 57600 4050000 128000 184320 240 v = 230400 216000 57600 4050000 128000 184320 480 v = 230400 216000 57600 4050000 128000 184320 1920 v = 230400 216000 57600 4050000 128000 184320 1920 2 v = 230400 216000 57600 4050000 128000 184320 1920 8 v = 230400 216000 57600 4050000 128000 184320 1920 8 v = 230400 216000 57600 4050000 128000 184320 1920 16 v = 230400 216000 57600 4050000 128000 184320 1920 32 v = 230400 216000 57600 4050000 128000 184320 1920 96 v = 230400 216000 57600 4050000 128000 184320 1920 480 v = 230400 216000 57600 4050000 128000 184320 1920 2400 v = 230400 216000 57600 4050000 128000 184320 1920 12000 v = 230400 216000 57600 4050000 128000 184320 1920 36000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 4 v = 230400 216000 57600 4050000 128000 184320 1920 180000 12 v = 230400 216000 57600 4050000 128000 184320 1920 180000 36 v = 230400 216000 57600 4050000 128000 184320 1920 180000 108 v = 230400 216000 57600 4050000 128000 184320 1920 180000 108 v = 230400 216000 57600 4050000 128000 184320 1920 180000 216 v = 230400 216000 57600 4050000 128000 184320 1920 180000 1080 v = 230400 216000 57600 4050000 128000 184320 1920 180000 5400 v = 230400 216000 57600 4050000 128000 184320 1920 180000 27000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 108000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 2 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 10 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 40 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 200 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 2000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 4000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 20000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 60000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 300000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 3 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 15 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 30 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 30 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 60 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 120 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 240 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 480 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 480 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 1920 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 3840 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 3840 2 v = 230400 216000 57600 4050000 128000 184320 1920 180000 540000 1500000 3840 2 v = 230400 216000 57600 405000...

### Community Treasure Hunt

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

Start Hunting!