Cody

Problem 2641. Dispatch and collect

Solution 2169759

Submitted on 22 Mar 2020
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   Fail
x = [1 2 6; 2 7 5; 3 5 4]; co1 = [1 2 4; 3 7 6]; co2 = [1 1 3; 3 2 1]; [o1, o2] = dispatch(x, @min, @max); assert(isequal(o1, co1) && isequal(o2, co2))

R = 1 2 4 R = 1 2 4 3 7 6 R = 1 2 4 3 7 6

One or more output arguments not assigned during call to "varargout". Error in Test1 (line 4) [o1, o2] = dispatch(x, @min, @max);

2   Fail
x = randi(50, 20); co = [mean(x); mode(x); median(x)]; assert(isequal(co, dispatch(x, @mean, @mode, @median)))

R = Columns 1 through 17 22.6000 22.6500 20.2500 24.2500 27.2000 22.5000 18.0000 23.1500 21.3000 30.0000 23.5500 31.7500 28.5000 22.1000 21.9000 23.1500 23.9000 Columns 18 through 20 23.1000 20.4000 23.0500 R = Columns 1 through 17 22.6000 22.6500 20.2500 24.2500 27.2000 22.5000 18.0000 23.1500 21.3000 30.0000 23.5500 31.7500 28.5000 22.1000 21.9000 23.1500 23.9000 11.0000 2.0000 30.0000 8.0000 38.0000 2.0000 2.0000 9.0000 6.0000 29.0000 6.0000 31.0000 33.0000 13.0000 3.0000 43.0000 43.0000 Columns 18 through 20 23.1000 20.4000 23.0500 2.0000 7.0000 19.0000 R = Columns 1 through 17 22.6000 22.6500 20.2500 24.2500 27.2000 22.5000 18.0000 23.1500 21.3000 30.0000 23.5500 31.7500 28.5000 22.1000 21.9000 23.1500 23.9000 11.0000 2.0000 30.0000 8.0000 38.0000 2.0000 2.0000 9.0000 6.0000 29.0000 6.0000 31.0000 33.0000 13.0000 3.0000 43.0000 43.0000 21.5000 20.5000 18.5000 20.0000 29.5000 18.5000 19.0000 23.5000 18.0000 30.0000 20.5000 35.5000 33.0000 20.0000 21.5000 20.5000 26.0000 Columns 18 through 20 23.1000 20.4000 23.0500 2.0000 7.0000 19.0000 21.5000 15.0000 22.5000 R = Columns 1 through 17 22.6000 22.6500 20.2500 24.2500 27.2000 22.5000 18.0000 23.1500 21.3000 30.0000 23.5500 31.7500 28.5000 22.1000 21.9000 23.1500 23.9000 11.0000 2.0000 30.0000 8.0000 38.0000 2.0000 2.0000 9.0000 6.0000 29.0000 6.0000 31.0000 33.0000 13.0000 3.0000 43.0000 43.0000 21.5000 20.5000 18.5000 20.0000 29.5000 18.5000 19.0000 23.5000 18.0000 30.0000 20.5000 35.5000 33.0000 20.0000 21.5000 20.5000 26.0000 Columns 18 through 20 23.1000 20.4000 23.0500 2.0000 7.0000 19.0000 21.5000 15.0000 22.5000

One or more output arguments not assigned during call to "varargout". Error in Test2 (line 3) assert(isequal(co, dispatch(x, @mean, @mode, @median)))

3   Fail
x=10; co = [zeros(x);ones(x);eye(x);magic(x);pascal(x)]; assert(isequal(co, dispatch(x, @zeros, @ones, @eye, @magic, @pascal)))

R = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 R = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 0 0 0 0 1 92 99 1 8 15 67 74 51 58 40 98 80 7 14 16 73 55 57 64 ...

One or more output arguments not assigned during call to "varargout". Error in Test3 (line 3) assert(isequal(co, dispatch(x, @zeros, @ones, @eye, @magic, @pascal)))

4   Fail
co = randi(50, 1, 4); [o1, o2, o3, o4] = dispatch(zeros(co), @size); assert(isequal([o1 o2 o3 o4], co))

R = 8 46 27 41 R = 8 46 27 41

One or more output arguments not assigned during call to "varargout". Error in Test4 (line 2) [o1, o2, o3, o4] = dispatch(zeros(co), @size);

Suggested Problems

More from this Author9

Community Treasure Hunt

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

Start Hunting!