Cody

Solution 2019509

Submitted on 14 Nov 2019 at 4:55 by Asif Newaz
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))

y(:,:,1) = 0.5793 0.8539 0.3475 0.0194 0.9744 0.9037 y(:,:,2) = 0.8270 0.9872 0.4227 0.6104 0.3685 0.8392 y(:,:,3) = 0.9538 0.7100 0.7351 0.6031 0.2924 0.3673 y(:,:,4) = 0.4172 0.8314 0.1632 0.5886 0.9146 0.2991

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

y(:,:,1) = 0.8230 0.3383 0.9341 0.7679 0.4717 0.1410 y(:,:,2) = 0.1001 0.8819 0.6314 0.7850 0.5745 0.8967 y(:,:,3) = 0.8410 0.3093 0.2927 0.1552 0.4934 0.4728 y(:,:,4) = 0.6725 0.0029 0.5507 0.7724 0.0178 0.1910

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

y(:,:,1,1) = 0.1226 0.7211 0.3775 0.7080 0.1498 0.3590 y(:,:,2,1) = 0.6481 0.5175 0.0614 0.2101 0.5237 0.9091 y(:,:,3,1) = 0.7365 0.3524 0.2199 0.1381 0.2444 0.4373 y(:,:,4,1) = 0.7267 0.5130 0.7338 0.2833 0.1562 0.4575 y(:,:,1,2) = 0.1671 0.6549 0.6279 0.1737 0.7620 0.1606 y(:,:,2,2) = 0.0143 0.3583 0.9318 0.7454 0.6940 0.7548 y(:,:,3,2) = 0.5264 0.6493 0.4863 0.4981 0.7392 0.3579 y(:,:,4,2) = 0.4054 0.1684 0.3581 0.4795 0.4751 0.3999 y(:,:,1,3) = 0.7547 0.9535 0.1678 0.9108 0.3848 0.2637 y(:,:,2,3) = 0.2198 0.4488 0.2472 0.4883 0.0528 0.0734 y(:,:,3,3) = 0.3618 0.9524 0.6285 0.9600 0.0974 0.0699 y(:,:,4,3) = 0.8915 0.5984 0.6576 0.1872 0.1062 0.8985 y(:,:,1,4) = 0.7249 0.3494 0.7274 0.5337 0.3075 0.1384 y(:,:,2,4) = 0.0648 0.8398 0.5429 0.5293 0.5719 0.7615 y(:,:,3,4) = 0.5571 0.9224 0.8354 0.1201 0.1410 0.9728 y(:,:,4,4) = 0.8156 0.6543 0.3822 0.4851 0.0049 0.0840 y(:,:,1,5) = 0.4887 0.1491 0.1861 0.7465 0.8978 0.0546 y(:,:,2,5) = 0.8401 0.2616 0.1680 0.2444 0.0128 0.0154 y(:,:,3,5) = 0.1490 0.8531 0.0901 0.4990 0.3096 0.6854 y(:,:,4,5) = 0.8108 0.1295 0.9426 0.7788 0.2485 0.9611