Cody

Solution 1611328

Submitted on 17 Aug 2018 by Ben Cappello
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')

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

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

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

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

A(:,:,1) = 0.6373 0.9463 0.9291 0.5014 0.6418 0.7690 0.1113 0.2271 0.2889 0.3035 0.1469 0.0177 0.1193 0.9429 0.6050 0.3800 0.2550 0.6516 0.8427 0.8600 0.0844 0.1491 0.8279 0 0.0510 0.2233 0.5867 0.1102 0.6925 0.9020 0.1284 0.2833 0.1353 0.0723 0.7896 0.7110 0.9088 0.1373 0.5227 0.5645 0.1034 0.9981 0.0789 0.3386 0.7452 0.3841 0.0172 0.2278 0.7415 0.7491 0.4071 0.4460 0.3798 0.8422 0.0927 0.3379 0.2470 0.3986 0.0405 0.2906 0.6416 0.9629 0.2196 0.7742 0.2986 0.8460 0.0764 0.3158 0.5006 0.0846 0.8005 0.2317 0.3872 0.1653 0.4257 0.1269 0.9696 0.4503 0.5635 0.4073 0.4147 0.0880 0.0594 0.4132 0.4169 0.9667 0.8166 0.9525 0.0972 0.8019 0.9603 0.4726 0.4015 0.7635 0.7473 0.2166 0.3213 0.0888 0.0149 0.4090 A(:,:,2) = 0.2478 0 0.8724 0.3431 0.4950 0.5545 0.3883 0.6674 0.1897 0.0791 0.5811 0.4626 0.3176 0.6118 0.1284 0.9161 0.0591 0.7185 0.8656 0.2417 0.7128 0.7727 0.1647 0.4066 0.7727 0.4038 0.8484 0.1091 0.2509 0.6334 0.0990 0.5967 0.1200 0.3966 0.2544 0.8266 0.8446 0.1073 0.3325 0.7485 0.3265 0.6768 0.6737 0.7722 0.6593 0.0801 0.1426 0.7294 0.1691 0.7770 0.9506 0.7590 0.1606 0.7756 0.5430 0.5067 0.0074 0.4619 0.5669 0.3910 0.3699 0.1209 0.9665 0.6295 0.4988 0.1990 0.6628 0.1778 0.9047 0.4503 0.5206 0.6374 0.4652 0.2778 0.4321 0.0848 0.6317 0.3140 0.0563 0.4595 0.3706 0.4253 0.2232 0.2206 0.0561 0.6249 0.8887 0.3389 0.8495 0.2513 0.3418 0.4262 0.4123 0.9427 0.9102 0.1189 0.0191 0.7076 0.5917 0.8758 A(:,:,3) = 0.1783 0.8650 0.0259 0.3097 0.5253 0.9361 0.6029 0.9697 0.7326 0.7382 0.9029 0.1781 0.1646 0.8538 0.5292 0.3167 0.3193 0.8594 0.3369 0.7046 0.6588 0.7655 0.7225 0.4634 0.4475 0.0785 0.0105 0.5134 0.3899 0.2521 0.9493 0.0027 0.6257 0.1043 0.3211 0.1536 0.5554 0.0877 0.6542 0.8440 0.4232 0.2797 0.7026 0.8631 0.7172 0 0.5875 0.2226 0.0756 0.3052 0.0030 0.9373 0.5300 0.4954 0.8037 0.8130 0.2028 0.7777 0.0975 0.2397 0.1706 0.6183 0.7575 0.6708 0.3642 0.6658 0.1781 0.1872 0.4638 0.7037 0.5973 0.1297 0.6378 0.4148 0.3513 0.8283 0.0177 0.7066 0.0344 0.3044 0.6409 0.1903 0.3362 0.5548 0.3466 0.0326 0.2364 0.7267 0.2702 0.8192 0.0773 0.2272 0.2141 0.7215 0.7610 0.6798 0.9615 0.9382 0.4958 0.6442 A(:,:,4) = 0.5487 0.9000 0.6962 0.2431 0.2804 0.2877 0.9518 0.3341 0.0300 0.0795 0.7592 0.2089 0.9954 0.6266 0.7394 0.1094 0.4613 0.9939 0.0693 0.5676 0.9494 0.5695 0.7705 0.9862 0.4756 0.4870 0.4789 0.2561 0.7191 0.2008 0.2190 0.2857 0.4195 0.9366 0.4346 0.1465 0.9632 0.1600 0.4539 0.1507 0.3831 0.6561 0.0965 0.6046 0.9633 0.4497 0.7306 0.0158 0.2942 0.4195 0.7275 0.5728 0.6007 0.1160 0.9968 0.3750 0.8818 0.0527 0.4557 0.3073 0.6925 0.8268 0.7866 0.7394 0.8515 0.2305 0.1923 0.4580 0.4530 0.8510 0.7631 0.9230 0.9976 0.2388 0.0603 0.5605 0.5801 0.5841 0.6351 0.7727 0.6712 0.8482 0.9755 0.9566 0.8338 0.2267 0.7186 0.2404 0.8553 0.2910 0.8503 0.4381 0.0956 0.9649 0.4411 0.2743 0.4487 0.1423 0.6142 0.7267 A(:,:,5) = 0.2467 0.5354 0.9732 0.7503 0.1334 0.3618 0.5984 0.4172 0.6156 0.6072 0.7610 0.5741 0.4315 0.4342 0.3251 0.7167 0.3285 0.5506 0.0669 0.4609 0.4862 0.0425 0.7854 0.4500 0.5610 0.5141 0.8433 0.7548 0.6908 0.5650 0.9952 0.2517 0.5746 0.5618 0.9767 0.3954 0.7573 0.8710 0.9389 0.4512 0.1201 0.1071 0.1000 0.2582 0.6085 0.3672 0.4540 0.4459 0.6864 0.5468 0.1092 0.7516 0.2527 0.4983 0.3857 0.9944 0.6736 0.9389 0.5514 0.8643 0.0888 0.0069 0.5091 0.7076 0.9825 0.3638 0.5452 0.4123 0.5361 0.4341 0.7899 0.4901 0.5468 0.0733 0.5835 0.5099 0.9981 0.4159 0.7982 0.5096 0.4405 0.3254 0.4729 0.9522 0.1044 0.2218 0.8044 0.4873 0.5473 0.2583 0.3553 0.5748 0.0495 0.0572 0.8054 0.7481 0.0697 0.0417 0.8219 0.9576 A(:,:,6) = 0.2858 0.0371 0.1816 0.0399 0.2568 0.6575 0.1453 0.9064 0.7230 0.1903 0.0253 0.6402 0.2748 0.1989 0.2426 0.5022 0.2889 0.5844 0.4499 0.3658 0.8378 0.2869 0.7742 0.1508 0.5087 0.0044 0.9602 0.0300 0.5712 0.4921 0.4073 0.4323 0.2114 0.9537 0.3853 0.2655 0.0544 0.6677 0.3071 0.4084 0.2203 0.4459 0.5131 0.3591 0.7808 0.5311 0.1251 0.5580 0.0528 0.9693 0.8563 0.3106 0.9016 0.6498 0.5615 0.8293 0.2451 0.6815 0.6919 0.4068 0.9643 0.4207 0.1052 0.3440 0.8645 0.6633 0.7321 0.6833 0.9665 0.4096 0.1566 0.1954 0.3531 0.2501 0.1322 0.2545 0.7587 0.0229 0.7781 0.7335 0.7958 0.3735 0.3130 0.4646 0.5175 0.9219 0.4414 0.9792 0.7997 0.2647 0.0857 0.1511 0.3587 0.7179 0.6983 0.7370 0.7923 0.1353 0.2074 0.0034 A(:,:,7) = 0.6543 0.2074 0.1334 0.5879 0.9424 0.7795 0.0723 0.2154 0.4807 0.9541 0.2669 0.8566 0.6908 0.5048 0.1469 0.7259 0.8597 0.9659 0.9246 0.2562 0.4184 0.8932 0.5382 0.4599 0.3152 0.0633 0.0589 0.4639 0.5851 0.6193 0.7209 0.0573 0.6124 0.9001 0.5383 0.9963 0.8716 0.5228 0.9117 0.6449 0.4457 0.8897 0.5467 0.4838 0.5069 0.5921 0.0309 0.7777 0.3452 0.1844 0.5595 0.6165 0.3191 0.8096 0.8027 0.1372 0.7623 0.1680 0.5628 0.0248 0.9494 0.8970 0.9523 0.6033 0.8054 0.1052 0.1189 0.4749 0.9345 0.3156 0.3207 0.3730 0.6025 0.6057 0.9056 0.7514 0.7276 0.8192 0.2719 0.6824 0.5587 0.1324 0.9390 0.3435 0.4225 0.1429 0.0562 0.2684 0.9280 0.0918 0.0517 0.8642 0.9443 0.5772 0.5663 0.1743 0.1626 0.2010 0.4139 0.4437 A(:,:,8) = 0.2626 0.5781 0.6725 0.3580 0.5030 0.7278 0.9129 0.5774 0.2075 0.0202 0.4245 0.1330 0.6180 0.6803 0.3959 0.1078 0.1005 0.4019 0.0023 0.8303 0.4014 0.5092 0.9714 0.1107 0.6169 0.4285 0.3346 0.3654 0.7982 0.9796 0.2699 0.2992 0.0084 0.8301 0.4774 0.1492 0.6575 0.8383 0.3819 0.7313 0.2720 0.9483 0.7868 0.3857 0.4000 0.0542 0.6031 0.7618 0.3376 0.1567 0.9260 0.4580 0.9098 0.9445 0.5921 0.1016 0.0438 0.4377 0.2940 0.9716 0.0106 0.5216 0.6752 0.0453 0.2693 0.1517 0.9252 0.3419 0.4676 0.1723 0.7830 0.8728 0.0825 0.1700 0.7935 0.8820 0.8375 0.1781 0.4290 0.7878 0.6900 0.7151 0.2908 0.9508 0.5641 0.2387 0.0676 0.1572 0.8598 0.5955 0.6390 0.6262 0.1527 0.7962 0.4013 0.1058 0.3109 0.7292 0.1949 0.4981 A(:,:,9) = 0.8711 0.7581 0.9668 0.3477 0.4434 0.8351 0.7802 0.3857 0.5391 0.7767 0.8071 0.9061 0.1119 0.4131 0.4672 0.2421 0.7545 0.6785 0.1055 0.3033 0.9294 0.0474 0.4065 0.9435 0.8502 0.9443 0.3308 0.8435 0.7781 0.5106 0.3160 0.4251 0.6648 0.5250 0.8199 0.3777 0.1727 0.8234 0.3260 0.9541 0.1987 0.1795 0.2250 0.1911 0.1627 0.5078 0.0932 0.9289 0.3286 0.4170 0.7675 0.8727 0.7635 0.6744 0.8073 0.6764 0.9126 0.0682 0.3811 0.2974 0.1592 0.2420 0.3636 0.1601 0.7467 0.8777 0.2362 0.9577 0.0291 0.4434 0.3673 0.9150 0.8801 0.3526 0.7764 0.1894 0.8234 0.3051 0.4497 0.1827 0.3433 0.7455 0.2400 0.0355 0.4742 0.1605 0.0043 0.6083 0.5227 0.2652 0.3166 0.1894 0.9927 0.4049 0.9727 0.3577 0.3497 0.2585 0.7247 0.3802 A(:,:,10) = 0.7609 0.7897 0.3674 0.8697 0.5417 0.5958 0.4995 0.5385 0.9880 0.1974 0.5370 0.2580 0.6875 0.9027 0.0162 0.6126 0.0284 0.6423 0.1716 0.3690 0.0724 0.4148 0.8850 0.0448 0.6993 0.5397 0.6623 0.1530 0.1047 0.9918 0.3227 0.6056 0.9808 0.3288 0.1221 0.0063 0.8224 0.2499 0.5832 0.1338 0.0100 0.7903 0.6407 0.0748 0.6389 0.9338 0.0786 0.3537 0.5712 0.7659 0.6604 0.7954 0.8390 0.8671 0.4412 0.4923 0.0480 0.8023 0.8693 0.5012 0.8869 0.7530 0.6281 0.5291 0.6236 0.8897 0.9699 0.7875 0.2200 0.5805 0.8430 0.1571 0.7043 0.1196 0.7926 0.8516 ...

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

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

A = 13.3000 B = 13.3000