Cody

Solution 891166

Submitted on 18 May 2016 by Jan Orwat
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Pass
a=magic(9)-30; b=[sum(a(:,1:3),2) sum(a(:,4:6),2) sum(a(:,7:9),2)]; assert(isequal(matrix_crunch(a),b));

2   Pass
a=rand(12); b=[sum(a(:,1:3),2) sum(a(:,4:6),2) sum(a(:,7:9),2) sum(a(:,10:12),2)]; m=matrix_crunch(a); assert(max(max(abs(m-b)))<1e-8)

3   Pass
a=ones(18); b=3*ones(18,6); assert(isequal(matrix_crunch(a),b))

4   Pass
a=magic(15)+j.*flipud(magic(15)); a=a(1:10,:)-rand(10,15); b=[sum(a(:,1:3),2) sum(a(:,4:6),2) sum(a(:,7:9),2) sum(a(:,10:12),2) sum(a(:,13:15),2)]; m=matrix_crunch(a); assert(max(max(abs(m-b)))<1e-8)