Cody

Solution 1942746

Submitted on 19 Sep 2019 by Augusto Mazzei
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
A = [2 0 1 3 5 7]; subsz = [1 2]; B = [1 2 6]; assert(norm(B-blkavg(A,subsz)) < 1e-10)

B = 1 B = 1 2 B = 1 2 6

2   Pass
A = [1 2 3 4 5 6 7 8 9].'; subsz = [3,1]; B = [2 5 8].'; assert(norm(B-blkavg(A,subsz)) < 1e-10)

B = 2 B = 2 5 B = 2 5 8

3   Pass
A = [1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 4 4 4 3 3 3 4 4 4]; subsz = [2 3]; B = [1 2 3 4]; assert(norm(B-blkavg(A,subsz)) < 1e-10)

B = 1 B = 1 2 B = 1 2 3 0 B = 1 2 3 4

4   Pass
A = rand(100,300); subsz = size(A); B = mean(A(:)); assert(norm(B-blkavg(A,subsz)) < 1e-10)

B = 0.4980

5   Pass
subsz = [4,6]; B = 10*rand(10,20); A = repelem(B,subsz(1),subsz(2)); assert(norm(B-blkavg(A,subsz)) < 1e-10)

B = 9.4038 B = 9.4038 3.2117 B = 9.4038 3.2117 4.4951 B = 9.4038 3.2117 4.4951 2.9808 B = 9.4038 3.2117 4.4951 2.9808 9.2482 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 B = 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 Column 19 6.3876 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 Columns 19 through 20 6.3876 7.2390 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 0 0 0 0 0 0 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 4.2873 0 0 0 0 0 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 4.2873 3.7378 0 0 0 0 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 4.2873 3.7378 7.6919 0 0 0 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 4.2873 3.7378 7.6919 9.1164 0 0 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 4.2873 3.7378 7.6919 9.1164 2.2826 0 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 4.2873 3.7378 7.6919 9.1164 2.2826 6.3630 0 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 4.2873 3.7378 7.6919 9.1164 2.2826 6.3630 2.6921 0 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 4.2873 3.7378 7.6919 9.1164 2.2826 6.3630 2.6921 7.7119 0 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 4.2873 3.7378 7.6919 9.1164 2.2826 6.3630 2.6921 7.7119 4.7126 0 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 4.2873 3.7378 7.6919 9.1164 2.2826 6.3630 2.6921 7.7119 4.7126 5.9548 0 0 Columns 19 through 20 6.3876 7.2390 0 0 B = Columns 1 through 18 9.4038 3.2117 4.4951 2.9808 9.2482 2.4191 4.5430 9.9314 8.1467 8.9102 1.2368 2.0018 4.4947 2.3843 4.6478 8.6001 2.8720 9.5806 7.5192 9.3587 5.6303 1.6143 9.3873 5.2864 ...