Cody

Solution 1653051

Submitted on 19 Oct 2018 by Wycliff Dembe
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
x = rand(2,3,1,4); y_correct = 3; assert(isequal(ndims(remove_dims(x)),y_correct))

ans(:,:,1) = 0.5999 0.8340 0.4210 0.3136 0.2456 0.3355 ans(:,:,2) = 0.5161 0.9717 0.3561 0.6488 0.5997 0.0723 ans(:,:,3) = 0.2894 0.2140 0.3328 0.3337 0.0283 0.6950 ans(:,:,4) = 0.0617 0.5762 0.2027 0.1017 0.3194 0.1803

2   Pass
x = rand(2,3,4); y_correct = 3; assert(isequal(ndims(remove_dims(x)),y_correct))

ans(:,:,1) = 0.3667 0.3787 0.5342 0.0099 0.3272 0.4698 ans(:,:,2) = 0.8117 0.9924 0.9867 0.2973 0.7511 0.2031 ans(:,:,3) = 0.3731 0.7638 0.4923 0.0534 0.8818 0.0575 ans(:,:,4) = 0.8362 0.5456 0.5469 0.7064 0.3055 0.1820

3   Pass
x = rand(1,2,3,4,5); y_correct = 4; assert(isequal(ndims(remove_dims(x)),y_correct))

ans(:,:,1,1) = 0.4171 0.2066 0.7984 0.1223 0.4991 0.1573 ans(:,:,2,1) = 0.7133 0.8357 0.0875 0.3452 0.4514 0.1389 ans(:,:,3,1) = 0.9330 0.9221 0.2430 0.8988 0.0721 0.6463 ans(:,:,4,1) = 0.2769 0.2717 0.9983 0.4137 0.4138 0.1829 ans(:,:,1,2) = 0.6852 0.5412 0.6166 0.8139 0.8840 0.7226 ans(:,:,2,2) = 0.3722 0.8911 0.4955 0.0344 0.5357 0.6072 ans(:,:,3,2) = 0.8100 0.0259 0.3677 0.3636 0.3492 0.9571 ans(:,:,4,2) = 0.0000 0.1095 0.0133 0.2804 0.6975 0.9010 ans(:,:,1,3) = 0.3559 0.0823 0.8481 0.4390 0.0055 0.3984 ans(:,:,2,3) = 0.3090 0.4414 0.0975 0.6110 0.8193 0.6275 ans(:,:,3,3) = 0.0039 0.5999 0.1944 0.3133 0.7513 0.5477 ans(:,:,4,3) = 0.7723 0.1124 0.5472 0.9444 0.5853 0.2349 ans(:,:,1,4) = 0.5055 0.4913 0.6488 0.2409 0.7896 0.3690 ans(:,:,2,4) = 0.1607 0.9091 0.8490 0.6164 0.7075 0.6893 ans(:,:,3,4) = 0.2455 0.6272 0.5295 0.8236 0.6091 0.9894 ans(:,:,4,4) = 0.1463 0.9637 0.0441 0.4597 0.3754 0.2880 ans(:,:,1,5) = 0.6451 0.7443 0.6141 0.3331 0.4435 0.5125 ans(:,:,2,5) = 0.9305 0.4480 0.9787 0.3275 0.5866 0.3894 ans(:,:,3,5) = 0.8135 0.6849 0.9048 0.9030 0.0160 0.4431 ans(:,:,4,5) = 0.1943 0.9831 0.3834 0.0539 0.9209 0.5548

Suggested Problems

More from this Author39