Cody

Solution 96294

Submitted on 7 Jun 2012 by @bmtran (Bryant Tran)
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
%% assert(isequal(accumcell(@plus,{1,2,3,4},0),10)) assert(isequal(accumcell(@times,{1,2,3,4},1),24)) assert(isequal(accumcell(@times,{1,2,3,4},0),0)) M = rand(3,4,5); C = num2cell(M,1:2); assert(isequal(accumcell(@plus,C,0),sum(M,3))) assert(isequal(accumcell(@times,C,1),prod(M,3)))

a = 1 a = 3 a = 6 a = 10 a = 1 a = 2 a = 6 a = 24 a = 0 a = 0 a = 0 a = 0 a = 0.8147 0.9134 0.2785 0.9649 0.9058 0.6324 0.5469 0.1576 0.1270 0.0975 0.9575 0.9706 a = 1.7719 1.0553 1.0707 1.0006 1.3912 1.0541 1.5064 1.0067 0.9273 1.0133 1.6132 1.9046 a = 2.4506 1.4475 1.7768 1.0468 2.1489 1.7096 1.5382 1.1039 1.6704 1.1845 1.8902 2.7280 a = 3.1455 1.4819 2.5423 1.5365 2.4660 2.1483 2.3334 1.5495 2.6206 1.5660 2.0770 3.3744 a = 3.8548 2.1616 2.6613 1.8769 3.2207 2.8034 2.8318 2.1347 2.8966 1.7286 3.0368 3.5982 a = 0.8147 0.9134 0.2785 0.9649 0.9058 0.6324 0.5469 0.1576 0.1270 0.0975 0.9575 0.9706 a = 0.7798 0.1296 0.2206 0.0345 0.4396 0.2667 0.5247 0.1338 0.1016 0.0893 0.6279 0.9065 a = 0.5293 0.0508 0.1558 0.0016 0.3331 0.1748 0.0167 0.0130 0.0755 0.0153 0.1739 0.7465 a = 0.3678 0.0018 0.1192 0.0008 0.1056 0.0767 0.0133 0.0058 0.0718 0.0058 0.0325 0.4825 a = 0.2609 0.0012 0.0142 0.0003 0.0797 0.0502 0.0066 0.0034 0.0198 0.0009 0.0312 0.1080