Cody

Solution 1851690

Submitted on 18 Jun 2019
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   Fail
A = randn(5,5); assert(isequal(arraySlice(A,4,2),A(:,4)))

S = -0.3260 1.3099 1.5499 -0.4337 -1.2873 1.3206 -1.3785 1.0978 -1.3755 -1.2900 -1.4557 1.7883 -2.5759 -1.5649 -0.8724 -0.2190 1.4713 -0.6903 0.3496 0.3829 2.2343 -0.6461 -0.8361 1.2349 1.3864 S = -0.2190 1.4713 -0.6903 0.3496 0.3829

Assertion failed.

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

S = 0.0739 0.1677 -0.4380 -0.6395 -0.8858 -0.8542 0.7056 -0.7184 -2.3555 0.7814 1.6392 0.0273 -2.1907 -0.8624 0.9821 0.8471 0.4195 -1.6395 1.3902 0.6488 -0.4150 -1.0151 0.7804 0.1062 -0.3901 S = 0.8471 0.4195 -1.6395 1.3902 0.6488

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

S(:,:,1) = -1.0161 1.0785 -0.0190 -1.6949 0.2293 S(:,:,2) = 0.3972 -2.2029 -0.9611 -0.2937 -1.3936 S(:,:,3) = 2.4972 2.2007 -0.3658 -1.0415 1.6823 S(:,:,4) = -1.0406 1.7527 0.9470 -2.3498 1.9915 S(:,:,5) = -0.2935 -1.6295 -0.5593 0.6845 0.4134 S = Columns 1 through 18 -1.0161 1.0785 -0.0190 -1.6949 0.2293 0.3972 -2.2029 -0.9611 -0.2937 -1.3936 2.4972 2.2007 -0.3658 -1.0415 1.6823 -1.0406 1.7527 0.9470 Columns 19 through 25 -2.3498 1.9915 -0.2935 -1.6295 -0.5593 0.6845 0.4134

Assertion failed.

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

S(:,:,1,1) = -2.2095 -0.7580 1.0699 0.6812 0.3092 0.1064 0.0939 0.9733 -0.7691 1.0793 0.4730 -0.0428 0.1088 -0.0080 -1.0234 S(:,:,2,1) = -0.7141 -1.5316 -1.8913 -0.3179 -0.7728 -0.3229 -1.5687 -0.2075 1.0558 0.0149 -0.7112 0.2363 0.7486 0.0607 -0.6426 S(:,:,3,1) = -1.3737 1.6125 0.5048 -0.4780 -2.1539 -0.3085 0.1035 0.2081 -0.3175 1.6640 -0.5090 -0.1087 -0.2329 1.2317 -1.4554 S(:,:,4,1) = 0.1365 0.1021 -0.4384 1.1888 0.7949 -0.0141 -1.0563 -0.5620 0.1223 1.3192 -1.2608 -0.4654 -1.5261 0.1439 -1.2191 S(:,:,5,1) = -0.3385 -0.1207 -0.8703 0.7979 0.6848 1.7960 -0.0357 0.7145 -0.3738 -0.0938 0.0849 0.7572 -0.4338 -0.3942 -1.2297 S(:,:,1,2) = 0.9562 -0.8240 -0.1105 1.3095 -0.1217 -0.4560 -0.6283 -0.3758 0.7926 0.3237 0.3367 -1.5277 0.6083 1.5522 -0.4245 S(:,:,2,2) = 1.1849 -0.4732 0.1575 1.0844 -1.8147 1.1280 -0.3929 -0.2731 0.0265 1.3728 -0.0670 0.3029 1.1498 -0.3993 1.3383 S(:,:,3,2) = -0.6575 0.5320 -1.4826 -1.0959 -1.0247 1.0259 0.8369 -0.7387 -1.1962 0.7599 0.3096 -1.1470 0.2379 0.8652 -0.7148 S(:,:,4,2) = -0.6257 1.1908 0.4813 -1.1218 1.0801 1.0077 -1.4801 -1.8161 -1.8495 0.7448 3.2981 -0.5062 0.6517 2.3876 -0.4652 S(:,:,5,2) = -2.1801 -0.8257 -1.3036 0.4571 -0.4454 -0.8122 0.9414 -2.0968 -0.6138 -0.1907 1.4305 -1.9714 -0.1980 -0.7876 0.2848 S(:,:,1,3) = 0.9504 0.5270 -0.3875 0.3995 0.4311 -0.6345 1.6204 0.2165 -1.2890 -0.5254 1.0527 1.1809 0.0141 0.7219 -0.2288 S(:,:,2,3) = 0.6410 1.7185 -1.3860 -0.5761 -0.4909 0.0598 -0.3188 0.1158 0.3280 -0.9415 -0.6977 0.4068 0.6191 0.7800 0.8784 S(:,:,3,3) = 0.2684 -1.1938 0.4960 0.5175 0.2519 0.8268 0.8554 -1.0115 -0.9175 -1.0259 2.2615 0.4645 1.2669 3.7504 1.1289 S(:,:,4,3) = 0.6310 -0.1833 0.8169 0.8876 -0.4354 -0.8515 -0.2708 -2.7220 -0.4941 0.0151 -1.1355 -0.4639 -0.6624 -0.3252 -2.1787 S(:,:,5,3) = -1.3644 -0.6345 0.5126 -0.6517 0.0406 1.0345 1.6936 -1.9979 1.7580 -1.4971 0.7977 0.7950 0.3444 -0.0881 -0.1885 S(:,:,1,4) = -0.1981 1.3654 0.4802 0.0578 -1.9042 0.6001 0.5324 1.6657 1.9172 1.0847 0.5361 -0.5831 0.9400 0.5982 1.2924 S(:,:,2,4) = 1.2963 0.6682 0.7040 -0.4713 -0.1106 0.7317 -1.4070 0.2187 0.7918 1.7211 1.7400 1.0327 -0.1176 0.3349 -2.3080 S(:,:,3,4) = -1.3327 -0.7011 -2.4971 0.9137 0.1885 0.2743 0.6392 0.7016 0.9271 1.4799 0.0629 -0.6759 0.1685 0.3408 -1.1438 S(:,:,4,4) = 0.1143 -0.0703 -0.2256 1.2145 -0.8768 0.1462 0.9469 0.9869 0.2367 0.5387 1.1914 -0.2306 -0.4208 0.2722 -1.0896 S(:,:,5,4) = 0.3837 -0.8588 1.8975 1.0118 2.6156 -0.1190 -0.4061 -1.5400 0.7424 0.3278 1.3415 0.7251 -0.3747 -0.7646 1.7442 S(:,:,1,5) = -1.0768 -0.3738 0.0252 -0.1739 -0.0108 -1.1300 -0.0769 0.5310 -0.5730 -1.7534 -1.3257 -0.5105 0.6389 1.1727 -0.1348 S(:,:,2,5) = -1.1054 -0.7292 -0.6846 0.9537 0.2565 -0.7442 1.7765 -2.3089 0.3736 -1.6248 -0.6925 0.6533 -0.0921 -0.4404 -0.7215 S(:,:,3,5) = 0.1917 1.3576 -0.2852 -1.6239 0.0120 -1.0427 0.4451 -0.9866 -2.0363 -0.9752 0.8233 -0.3586 3.0869 -0.0740 -0.5718 S(:,:,4,5) = -0.3201 -1.7698 0.9338 1.7601 1.9737 -1.2282 0.2244 -1.2817 0.3998 -0.0285 0.3695 -0.4534 -0.0800 -0.7848 -0.1094 S(:,:,5,5) = 0.3551 -1.2778 1.3878 -0.4254 -0.7949 0.6889 0.0864 -0.2112 2.8766 -0.4612 1.3907 -2.1606 -0.0787 0.1244 2.0311 S = Columns 1 through 18 0.4730 -0.0428 0.1088 -0.0080 -1.0234 -0.7112 0.2363 0.7486 0.0607 -0.6426 -0.5090 -0.1087 -0.2329 1.2317 -1.4554 -1.2608 -0.4654 -1.5261 Columns 19 through 36 0.1439 -1.2191 0.0849 0.7572 -0.4338 -0.3942 -1.2297 0.3367 -1.5277 0.6083 1.5522 -0.4245 -0.0670 0.3029 1.1498 -0.3993 1.3383 0.3096 Columns 37 through 54 -1.1470 0.2379 0.8652 -0.7148 3.2981 -0.5062 0.6517 2.3876 -0.4652 1.4305 -1.9714 -0.1980 -0.7876 0.2848 1.0527 1.1809 0.0141 0.7219 Columns 55 through 72 -0.2288 -0.6977 0.4068 0.6191 0.7800 0.8784 2.2615 0.4645 1.2669 3.7504 1.1289 -1.1355 -0.4639 -0.6624 -0.3252 -2.1787 0.7977 0.7950 Columns 73 through 90 0.3444 -0.0881 -0.1885 0.5361 -0.5831 0.9400 0.5982 1.2924 1.7400 1.0327 -0.1176 0.3349 -2.3080 0.0629 -0.6759 0.1685 0.3408 -1.1438 Columns 91 through 108 1.1914 -0.2306 -0.4208 0.2722 -1.0896 1.3415 0.7251 -0.3747 -0.7646 1.7442 -1.3257 -0.5105 0.6389 1.1727 -0.1348 -0.6925 0.6533 -0.0921 Columns 109 through 125 -0.4404 -0.7215 0.8233 -0.3586 3.0869 -0.0740 -0.5718 0.3695 -0.4534 -0.0800 -0.7848 -0.1094 1.3907 -2.1606 -0.0787 0.1244 2.0311

Assertion failed.

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)))

S = 0.4741 0.6122 S = 0.6122

Suggested Problems

More from this Author57