Cody

Solution 1175054

Submitted on 29 Apr 2017 by Arief Anbiya
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 = randn(5,5); assert(isequal(arraySlice(A,4,2),A(:,4)))

ans = 0.4794 0.4517 1.2143 -0.3406 0.1623

2   Pass
A = randn(5,5); assert(isequal(arraySlice(A,4,1),A(4,:)))

ans = 0.3538 0.2349 -0.9276 -0.5136 -0.4204

3   Pass
A = randn(5,5); assert(isequal(arraySlice(A,1,10),A))

4   Pass
A = randn(5,5,5,3); assert(isequal(arraySlice(A,3,4),A(:,:,:,3)))

ans(:,:,1) = -1.3359 0.5662 -0.3473 -1.6824 -0.2247 0.4695 -2.0990 0.2595 0.7918 0.3957 -0.0353 -0.7117 0.9364 -0.5248 -0.1480 -0.2515 -0.7186 0.5057 -0.5143 -0.8272 -0.1677 -0.8864 0.5982 -0.1008 -1.0087 ans(:,:,2) = -1.2403 0.9806 -0.4061 -1.0391 -0.6994 -0.5237 0.8327 2.2962 0.1204 0.2442 -0.6642 0.3187 -0.4266 0.7048 1.0076 0.1706 -0.5066 0.6610 -0.9234 0.2850 -0.5037 -1.5384 -0.1527 -1.4607 -1.2347 ans(:,:,3) = -0.5869 -0.1949 -0.4602 0.1302 -0.1973 -1.0957 -2.0063 0.5880 0.1569 -0.9478 0.1678 -0.8161 1.1562 0.2260 -0.1883 -0.3889 0.2279 0.6973 -0.6932 -0.8303 -0.6119 1.5571 0.1342 0.7571 -0.4366 ans(:,:,4) = -0.1771 0.4173 1.3769 -0.3446 0.4141 -0.4752 -0.5828 -0.2092 1.0075 0.6909 -0.1630 -0.7402 0.2413 -0.9301 0.7080 -0.1583 -1.4955 0.7108 -0.4627 -0.4399 0.7048 0.0409 -0.0732 -2.0523 1.3145 ans(:,:,5) = -1.9470 0.0591 0.0617 2.1140 1.1611 -0.7695 1.2361 0.3209 0.6657 -1.0273 0.8551 -0.6883 1.5102 1.7922 0.1848 0.5919 -0.1282 1.0103 0.2847 1.1675 -0.3406 -0.1055 0.9020 1.1282 0.9170

5   Pass
A = randn(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2); assert(isequal(arraySlice(A,2,18),A(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,2)))

ans = 0.0359