Cody

# Problem 750. Accumulate Cells

Solution 467979

Submitted on 8 Jul 2014 by rifat
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)))

s = 1 s = 3 s = 6 s = 10 s = 1 s = 2 s = 6 s = 24 s = 0 s = 0 s = 0 s = 0 s = 0.2879 0.8310 0.5347 0.0936 0.1613 0.5363 0.5931 0.8446 0.7194 0.0261 0.8734 0.1755 s = 0.5509 1.5036 0.7375 0.3163 0.2396 0.5993 0.7414 1.3754 0.7909 0.8055 1.7756 1.0875 s = 1.3410 2.3044 0.8391 0.4789 1.1089 0.6154 1.1386 1.7679 0.8485 0.8546 1.9958 1.6354 s = 1.7239 2.9644 1.6045 0.5429 1.7749 0.8544 1.2287 2.5683 0.9667 1.4556 2.1076 2.5229 s = 2.5008 3.3076 2.5299 0.5511 2.3831 1.1723 2.0819 3.0378 1.9551 1.6040 2.7397 2.6290 s = 0.2879 0.8310 0.5347 0.0936 0.1613 0.5363 0.5931 0.8446 0.7194 0.0261 0.8734 0.1755 s = 0.0757 0.5589 0.1084 0.0208 0.0126 0.0338 0.0879 0.4483 0.0514 0.0204 0.7879 0.1601 s = 0.0598 0.4476 0.0110 0.0034 0.0110 0.0005 0.0349 0.1760 0.0030 0.0010 0.1736 0.0877 s = 0.0229 0.2954 0.0084 0.0002 0.0073 0.0001 0.0031 0.1408 0.0004 0.0006 0.0194 0.0779 s = 0.0178 0.1014 0.0078 0.0000 0.0044 0.0000 0.0027 0.0661 0.0003 0.0001 0.0123 0.0083