Cody

Problem 824. Set the array elements whose value is 13 to 0

Solution 3022684

Submitted on 1 Oct 2020 at 19:43 by Pink_panther
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 = [15 13 3]; y_correct = [15 0 3]; assert(isequal(your_fcn_name(A),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

n = 3 A = 15 0 3 B = 15 0 3

2   Pass
A = 13; y_correct = 0; assert(isequal(your_fcn_name(A),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

n = 1 A = 0 B = 0

3   Pass
A = []; y_correct = []; assert(isequal(your_fcn_name(A),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

n = 0 A = [] B = []

4   Pass
A = [13 0 13; 13 13 8; 13 25 2]; titi = [0 0 0 ; 0 0 8;0 25 2]; assert(isequal(your_fcn_name(A),titi)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

n = 9 A = 0 0 0 0 0 8 0 25 2 B = 0 0 0 0 0 8 0 25 2

5   Pass
A=rand(10,10,10); A(1,2,2)=13; A(3,4,1)=13; A(5,6,3)=13; % what you cannot do but me I can ;) ! titi = A; I=find(titi==13); [u,v,w]=ind2sub(size(titi),I); for ii = 1 : numel(u) titi(u(ii),v(ii),w(ii))=0; end assert(isequal(your_fcn_name(A),titi)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

n = 1000 A(:,:,1) = 0.0261 0.8313 0.7729 0.1668 0.9534 0.3437 0.7282 0.0349 0.3225 0.1355 0.4734 0.6384 0.9498 0.3748 0.5085 0.1854 0.1138 0.8843 0.4633 0.0477 0.9961 0.1452 0.8953 0 0.7811 0.0218 0.8456 0.7659 0.6260 0.3804 0.3120 0.6451 0.3604 0.9794 0.8985 0.7859 0.9273 0.0269 0.0862 0.8002 0.6509 0.6878 0.2729 0.5780 0.4510 0.2787 0.1273 0.8444 0.0120 0.7424 0.7867 0.4441 0.3631 0.4109 0.8988 0.4962 0.3074 0.7244 0.1734 0.8987 0.6261 0.3930 0.9781 0.6244 0.3487 0.2117 0.3921 0.2066 0.2998 0.0642 0.4249 0.7319 0.2135 0.7938 0.2102 0.4220 0.6662 0.5539 0.4368 0.5294 0.6755 0.9543 0.4709 0.2727 0.6647 0.6865 0.8486 0.2133 0.9567 0.8858 0.8665 0.7917 0.8211 0.9882 0.3253 0.8379 0.0751 0.2481 0.5795 0.7763 A(:,:,2) = 0.0246 0 0.2568 0.0237 0.2607 0.6192 0.6161 0.2484 0.7862 0.5569 0.0386 0.9244 0.3206 0.3205 0.8083 0.0102 0.5966 0.5361 0.0308 0.0721 0.0102 0.0062 0.1185 0.5294 0.3226 0.4723 0.5585 0.4853 0.4201 0.7255 0.1166 0.6625 0.5625 0.5508 0.6187 0.5377 0.9036 0.8728 0.2199 0.2562 0.7387 0.3743 0.6483 0.1901 0.2537 0.4699 0.8732 0.9119 0.0623 0.6608 0.8620 0.1806 0.7755 0.0143 0.9528 0.2804 0.4320 0.9867 0.8960 0.9174 0.8291 0.5411 0.4648 0.6117 0.6566 0.3591 0.5676 0.3284 0.9593 0.3441 0.5119 0.3076 0.6446 0.0887 0.2806 0.7606 0.4649 0.6692 0.8429 0.0283 0.5301 0.3922 0.3764 0.4500 0.4287 0.7979 0.0766 0.6363 0.7786 0.9178 0.3709 0.2700 0.7938 0.0499 0.1560 0.5425 0.1102 0.7411 0.9031 0.2229 A(:,:,3) = 0.5613 0.9731 0.0005 0.7982 0.8944 0.5104 0.5859 0.6384 0.2804 0.7197 0.3179 0.1221 0.9705 0.9399 0.0101 0.3994 0.6378 0.1876 0.9008 0.8274 0.3547 0.4931 0.3315 0.9712 0.0545 0.8214 0.0209 0.7157 0.7827 0.8542 0.9753 0.1888 0.7613 0.2496 0.1997 0.7469 0.3256 0.9565 0.6459 0.5854 0.0561 0.8233 0.7455 0.6514 0.9907 0 0.0408 0.8526 0.7582 0.2592 0.5664 0.1079 0.1761 0.3400 0.7669 0.5160 0.8982 0.9339 0.2014 0.9465 0.0153 0.5875 0.6869 0.4327 0.9669 0.8789 0.0800 0.5352 0.7607 0.5802 0.9640 0.4243 0.0404 0.9857 0.7041 0.7564 0.9499 0.1878 0.7454 0.6116 0.9923 0.0437 0.0847 0.7524 0.5408 0.2336 0.8998 0.9200 0.6908 0.8924 0.4795 0.7910 0.4339 0.2077 0.8771 0.4439 0.0526 0.5456 0.2234 0.2262 A(:,:,4) = 0.6357 0.6344 0.5492 0.4033 0.9373 0.4070 0.2624 0.9406 0.9906 0.0838 0.0609 0.0787 0.4292 0.6497 0.8942 0.3540 0.8441 0.5521 0.7757 0.1554 0.1757 0.8014 0.1865 0.1627 0.3153 0.0169 0.4327 0.6663 0.8643 0.5495 0.2080 0.3396 0.9018 0.3696 0.0797 0.0795 0.1771 0.5935 0.3261 0.3734 0.5382 0.0164 0.0273 0.0465 0.2763 0.2930 0.8876 0.0642 0.4964 0.8534 0.1836 0.1540 0.0234 0.3343 0.5762 0.2512 0.5123 0.8914 0.9363 0.3841 0.1033 0.3476 0.2359 0.0024 0.1948 0.6627 0.9272 0.7407 0.6518 0.5001 0.9793 0.2393 0.3902 0.3210 0.2344 0.2085 0.2508 0.6461 0.5191 0.5591 0.3294 0.3153 0.6711 0.7437 0.1501 0.7008 0.6657 0.6324 0.6286 0.9425 0.8468 0.5916 0.8946 0.6837 0.9282 0.6200 0.9750 0.9183 0.4279 0.6354 A(:,:,5) = 0.5274 0.5191 0.2062 0.7438 0.3445 0.5787 0.8186 0.5848 0.8884 0.7994 0.3743 0.2081 0.2864 0.6935 0.3023 0.5566 0.5772 0.3152 0.1496 0.2747 0.0745 0.8606 0.1851 0.8841 0.4883 0.7010 0.6876 0.0841 0.0967 0.0978 0.0401 0.0063 0.7655 0.1270 0.8703 0.7070 0.7889 0.6750 0.9875 0.5115 0.3280 0.7192 0.2327 0.1690 0.7416 0.2617 0.4503 0.7071 0.9445 0.5753 0.9785 0.1361 0.2208 0.6794 0.9952 0.8418 0.3704 0.8848 0.5205 0.2131 0.9367 0.2415 0.9554 0.5673 0.8229 0.0842 0.4006 0.4690 0.6825 0.1078 0.2493 0.5928 0.6386 0.1588 0.8135 0.1255 0.8276 0.0716 0.4727 0.3175 0.2329 0.1968 0.2899 0.5010 0.0133 0.7399 0.9274 0.6124 0.4465 0.7497 0.2074 0.4174 0.3416 0.2913 0.5264 0.3040 0.2579 0.1594 0.2419 0.2051 A(:,:,6) = 0.1192 0.0088 0.3997 0.2425 0.5931 0.4717 0.8622 0.1068 0.2694 0.5999 0.8651 0.3074 0.3200 0.6206 0.5766 0.0545 0.2229 0.1957 0.1080 0.9493 0.6849 0.9383 0.1907 0.3202 0.5118 0.0312 0.9560 0.1977 0.4983 0.0237 0.4938 0.4630 0.5609 0.4575 0.7440 0.7384 0.6926 0.1111 0.1192 0.7902 0.5620 0.8720 0.9429 0.3751 0.1129 0.3321 0.8505 0.4987 0.2986 0.3920 0.5260 0.3052 0.2612 0.7670 0.8486 0.5720 0.7030 0.8666 0.8779 0.5445 0.8348 0.8752 0.1759 0.3612 0.6131 0.1959 0.7990 0.1621 0.3380 0.2008 0.6364 0.3303 0.4059 0.5291 0.0593 0.3285 0.1248 0.2680 0.2737 0.5678 0.7178 0.8316 0.7592 0.8735 0.2886 0.9461 0.4133 0.7993 0.8078 0.7728 0.2011 0.1936 0.1700 0.6081 0.9502 0.0519 0.6400 0.5529 0.6545 0.7004 A(:,:,7) = 0.7717 0.0101 0.3528 0.7687 0.8888 0.9911 0.4929 0.4707 0.4463 0.6307 0.7752 0.2500 0.9217 0.6935 0.9016 0.8251 0.9322 0.0992 0.6757 0.7701 0.3132 0.1781 0.6208 0.8511 0.2168 0.0464 0.1998 0.2017 0.9705 0.0443 0.4644 0.2344 0.2112 0.5033 0.6150 0.2963 0.6709 0.5350 0.1550 0.6305 0.2246 0.3652 0.7243 0.6352 0.1251 0.8665 0.8522 0.1673 0.4542 0.6393 0.0156 0.1219 0.8536 0.6214 0.4363 0.0109 0.1922 0.1968 0.1793 0.4367 0.1109 0.0644 0.8485 0.1261 0.5845 0.3132 0.7232 0.3186 0.1211 0.0994 0.8091 0.5699 0.3673 0.5839 0.7667 0.0672 0.7819 0.0168 0.5390 0.8850 0.5276 0.3300 0.9983 0.7814 0.4547 0.6071 0.1049 0.9875 0.1534 0.0449 0.6745 0.6208 0.9434 0.8539 0.1402 0.6099 0.5517 0.9136 0.7462 0.2591 A(:,:,8) = 0.9904 0.4818 0.6274 0.8502 0.9272 0.2636 0.2010 0.5124 0.7748 0.1268 0.4383 0.0834 0.6568 0.9444 0.3298 0.1451 0.2132 0.4587 0.5005 0.4208 0.2543 0.4430 0.0156 0.8150 0.2814 0.7736 0.4438 0.4299 0.7475 0.5776 0.9090 0.7853 0.1567 0.4939 0.8219 0.8958 0.8026 0.1654 0.1181 0.5016 0.9644 0.3862 0.3760 0.9028 0.3405 0.1826 0.9084 0.2767 0.1395 0.0434 0.4386 0.3949 0.1962 0.1427 0.3336 0.4924 0.0031 0.4147 0.4195 0.9685 0.9402 0.3432 0.7632 0.4759 0.3919 0.8411 0.2025 0.1141 0.6325 0.3102 0.6887 0.6820 0.9044 0.9955 0.4660 0.3711 0.5383 0.0044 0.2672 0.6899 0.6313 0.2086 0.0196 0.3403 0.9104 0.7320 0.9081 0.7479 0.2754 0.2454 0.5727 0.8225 0.0665 0.0683 0.5956 0.8048 0.8121 0.3712 0.6512 0.8522 A(:,:,9) = 0.5228 0.7243 0.9641 0.0882 0.0365 0.3980 0.9691 0.0499 0.1873 0.2483 0.6477 0.2090 0.4213 0.7374 0.9040 0.5332 0.1095 0.5884 0.0851 0.9852 0.3102 0.6748 0.4202 0.8443 0.5995 0.5158 0.7709 0.9507 0.5132 0.3635 0.1350 0.6018 0.1407 0.1979 0.1995 0.3612 0.2132 0.1328 0.0890 0.6988 0.5868 0.5687 0.8362 0.7741 0.3654 0.5831 0.9002 0.7533 0.6948 0.0757 0.2211 0.5919 0.2442 0.1159 0.5877 0.7970 0.6699 0.0601 0.8144 0.6514 0.8804 0.2881 0.5727 0.1190 0.3930 0.6400 0.0500 0.0401 0.8727 0.8890 0.0440 0.9860 0.2333 0.3502 0.1564 0.9781 0.0983 0.4690 0.6296 0.4071 0.9715 0.0003 0.7513 0.8772 0.7177 0.8868 0.4761 0.3247 0.7688 0.0847 0.6210 0.6542 0.1330 0.9945 0.0419 0.7029 0.8554 0.3069 0.8552 0.8464 A(:,:,10) = 0.5421 0.1078 0.3877 0.8571 0.0442 0.4064 0.1056 0.1956 0.4645 0.7195 0.6193 0.3098 0.0657 0.9538 0.6922 0.0324 0.7536 0.7753 0.0528 0.8198 0.1978 0.7555 0.7212 0.9498 0.5454 0.5855 0.4293 0.2802 0.9211 0.9888 0.7920 0.3075 0.8019 0.6368 0.9117 0.2050 0.0820 0.8660 0.8812 0.3805 0.2868 0.8050 0.6951 0.8820 0.6972 0.6075 0.1228 0.9251 0.6547 0.5731 0.0057 0.8360 0.7085 0.4399 0.1709 0.3285 0.8000 0.1670 0.5114 0.1823 0.8304 0.9505 0.0320 0.2234 0.2692 0.2649 0.6347 0.6964 0.4021 0.6109 0.9865 0.1188 0.1154 0.7033 ...

6   Pass
A = repmat(13,89,17); assert(isequal(your_fcn_name(A),repmat(0,89,17))) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

n = 1513 A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 B = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

7   Pass
A= magic(5); B =A; B(3,3) = 0 assert(isequal(your_fcn_name(A),B)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = 17 24 1 8 15 23 5 7 14 16 4 6 0 20 22 10 12 19 21 3 11 18 25 2 9 n = 25 A = 17 24 1 8 15 23 5 7 14 16 4 6 0 20 22 10 12 19 21 3 11 18 25 2 9 B = 17 24 1 8 15 23 5 7 14 16 4 6 0 20 22 10 12 19 21 3 11 18 25 2 9

8   Pass
A= 13.3; B = A; assert(isequal(your_fcn_name(A),B))

n = 1 A = 13.3000 B = 13.3000

Suggested Problems

More from this Author30

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!